I wrote a web method function for login page. When a user successfully authenticates to a server I want to redirect him to a special page with specified va
[WebMethod]
public static string loginmtd(string username, string password , string chk)
{
datatable dt=filltable();//for bring data
if (dt.Rows.Count==1)
{
if (chk == "ok")
{
HttpCookie cook = new HttpCookie("userauth");
cook["user"] = usern;
cook["pass"] = passw;
HttpContext.Current.Response.Expires = 60000;
HttpContext.Current.Response.AppendCookie(cook);
}
HttpContext.Current.Response.Redirect("master.aspx?uid=" + username);
return result;
}
else
{
result = "no";
}
}
You don’t do this on a server side for web methods. This is a client responsibility.
You can follow a different algorithm:
Also have a look at HTTP status codes 3xx, they are responsible for redirects that a client may or may not follow.