1

I want to pass this query string to some aspx file ( WebForm1.aspx).But in here i'm unable to pass it.This is MVC5 application.Everything working but response.redirect not working

 public JsonResult SubmitReportData(SelectedReportViewModel SubmitData)
    {
        Response.Redirect("~/Report/WebForm1.aspx?Id="+SubmitData.SelectedNode+"&stDate="+SubmitData.stDate+"&enDate"+SubmitData.enDate);



        //return Json(new { x = 1 });
       return null;

    }
Alex
  • 223
  • 3
  • 13
  • You can return the path as string and use window.location.href='Your Path' to redirect in jquery. – Umesh Sehta Mar 02 '15 at 05:23
  • @sehtaumesh When i use that, then it shows 'The name windows doesn't exists in the current context' – Alex Mar 02 '15 at 05:25
  • possible duplicate of http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call – Jenish Rabadiya Mar 02 '15 at 05:26
  • Use can try this as well Response.Redirect("Your Path",True); – Umesh Sehta Mar 02 '15 at 05:30
  • and remove the "~" tilde symbol from the path , and should Report is your root folder. – Umesh Sehta Mar 02 '15 at 05:34
  • 1
    I'm going to assume that you are calling this via AJAX. Most AJAX libraries will only consider a response code of 200 as success by default, a redirect is 302 (generally). Remember it is JavaScript that is handling the response, not the browser directly so you will need to use javascript for the redirect on the client. – Jon P Mar 02 '15 at 06:30

1 Answers1

4

You can return the path as string in Jquery and use as

window.location.href='Your Path';

to redirect to another page.

Eg:

public JsonResult SubmitReportData(SelectedReportViewModel SubmitData)
{
   string path="~/Report/WebForm1.aspx?Id="+SubmitData.SelectedNode+"&stDate="+SubmitData.stDate+"&enDate"+SubmitData.enDate;
   return Json(path,JsonRequestBehavior.AllowGet);
}
Narek Mamikonyan
  • 4,601
  • 2
  • 24
  • 30
Umesh Sehta
  • 10,555
  • 5
  • 39
  • 68