Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to redirect to another page in web method

i have used but page not redirect.

C#
[WebMethod]
    public static void Go_BDPolicy(string pol)
    {
        string result = "Welcome Mr. " + pol + "";
        HttpContext.Current.Response.Redirect("~/DirectCSD/BusinessDeveloper.aspx",false);

    }
Posted
Comments
Murugesan22 4-Jul-14 6:17am    
You cant call response inside webmethod

Check here

http://stackoverflow.com/questions/17073362/cant-call-response-redirect-inside-a-static-method

C#
In your webmethod change like this:

[WebMethod]
public static void Go_BDPolicy(string pol)
{
return "Any Msg";
}

In success part of your code change like:
success: function (Result) {
var msg = Result.d;
if (msg == "Any Msg")
{
window.location.href = "Page.aspx";
}
}

I executed and it works :) :D
 
Share this answer
 
Comments
Devaraneni Laxman Rao 10-Feb-17 4:12am    
In Shared web method how we can redirect the page
Try with

C#
Response.Redirect("BusinessDeveloper.aspx");
 
Share this answer
 
Comments
Amit Vasi 4-Jul-14 6:04am    
Response.redirect method not call in web static method....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900