title: Message from stored procedure to alert box in view
body: <p>I am sending parameters to a stored procedure and the stored procedure return a message back, it's either a success or an error.</p>
  <pre><code>public IActionResult Index() =&gt; View();
  
  public async Task&lt;IActionResult&gt; Upload(IFormFile file) 
  {
      int cmdResponse = Convert.ToInt32(cmd.Parameters[&quot;@response&quot;].Value);
              string cmdMessage = cmd.Parameters[&quot;@message&quot;].Value.ToString();
              if (cmdResponse == 0)
              {
                  con.Close();
                  return RedirectToAction(&quot;Index&quot;, Json(new { status = &quot;error&quot;, message = cmdMessage }));
              }
              return RedirectToAction(&quot;Index&quot;, Json(new { status = &quot;success&quot;, message = cmdMessage }));
  
  }
  </code></pre>
  <p>and here is the view with the Javascript where I try to display the message from the stored procedure in an alert box.</p>
  <pre><code>&lt;script&gt;
  
      $(function () {
          $(&quot;#btn&quot;).click(function () {
              dangerResponseMessage('btn');
          });
      });
  
      function dangerResponseMessage(result) {
          var url = window.rootUrl + 'Upload/Upload';
  
          $.ajax({
              type: &quot;GET&quot;,
              url: url,
              dataType: 'json',
              success: function (result) {
                  alert(result.message);
              },
              error: function (xhr, ajaxOptions, thrownError) {
                  alert(result.message);
              }
          });
      }
  &lt;/script&gt;
  </code></pre>
  <p>The problem is that the alert box displays undefined
  <a href="https://i.stack.imgur.com/C3hzg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C3hzg.png" alt="enter image description here" /></a></p>
  <p>and when I dismiss the alert, it return the message from the stored procedure in the URL in the browser.
  <a href="https://i.stack.imgur.com/rWZC8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rWZC8.png" alt="enter image description here" /></a></p>
  <p>The cyrillic sentence in the URL is the message I am trying to display in the alert box.
  <a href="https://i.stack.imgur.com/2CZqo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2CZqo.png" alt="Correct value for cmdMessage" /></a>
  The ajax call is without data, since I don't need to send anything from the view to the controller.
  Any ideas as why is it showing the message in the URL and not in the alert box?</p>