window.location not genareted correctly in browser RRS feed

All replies

  • User475983607 posted

    The Razor and JavaScript has syntax errors.  


    If you are still having issues after fixing the typos, then post all the relevant code.  That will help us to help you.

    Friday, March 9, 2018 1:38 PM
  • User-775001650 posted

    Thanks for your reply,

    The below code generated from C# string builder and attached to data table. I am trying put window.location in single quote but it is generated like above post.

    StringBuilder Script='$.ajax({

    type: "get", url: "/SomeController/ActionMethod1",

    data: { accountNumber: accountNumber }, dataType: 'json',

    success: function(response)

    { if (response == null)

    { window.location.href = '@Url.Action(""Signoff"")'; }

    else { $(target).html(response); } },

    error:function(response){$(target).html('An error occured'); }});';

    Friday, March 9, 2018 1:48 PM
  • User475983607 posted

    Your approach will not work as Razor code runs on the server.  I assume the StringBuilder is in an action method.  You'll need to hard code the URL or use data driven design.

    For the second time, if you want help you'll need to post all the relevant code.  

    Friday, March 9, 2018 1:54 PM