title: Return JavaScript call from the controller of ASP.NET MVC 4 Razor
body: <p>I want to handle some errors in my ASP.NET MVC 4 project. Earlier I was developing WebForms applications and I've used <code>Page.ClientScript.RegisterClientScriptBlock</code>, but MVC != WebForms with its server controls, postbacks etc... So I'm a little bit confused.</p>
  
  <p>Of course I can return from the Controller a JSON response using smth like <code>return Json(...)</code>, but wait.</p>
  
  <p>I have a View. It has an exact markup. How does my View recognize which modalbox I must call from my jQuery + bootstap code?</p>
  
  <p><strong>First of all, I thought to use GET parameters for handling query string.</strong></p>
  
  <p>If /Index/UserNotExist -> Than call a jQuery function with showing custom modalbox</p>
  
  <p>Else if other some URL -> Than call a jQuery function with showing the same modalbox, but with other text in it.</p>
  
  <p>I've tried to use some code to handle current location, but failed (strange, that it the end of script block some jQuery's script are well running, but exact that script even wasn't firing).</p>
  
  <p><strong>Then I thought about cookies, to write temp data in cookie and make a simple check.</strong></p>
  
  <p>But in WebForms such a check in code <code>if (Request.Cookies["error"] != null</code> is running well, MVC doesn't even accept such a check it would always make exceptions.</p>
  
  <p>I'm a little bit tired and want to listen to your suggestions.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks</p>