O
omer013
Hi;
I have an aspx page with a WebMethod to redirect the user to another page.
The Default.aspx.cs is;
public partial class _Default : System.Web.UI.Page
{
[WebMethod]
public static void redirect_user()
{
HttpContext.Current.Response.Redirect("home.aspx");
}
}
and Default.aspx file;
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
function Button1_onclick()
{
PageMethods.redirect_user(redirectSuccess, redirectError);
}
function redirectSuccess(result)
{
alert(result);
}
function redirectError(error)
{
alert(error.get_message());
}
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="True" >
</asp:ScriptManager>
<div>
<input id="Button1" type="button" value="button" onclick="return
Button1_onclick()" />
</div>
</form>
</body>
</html>
When i use HttpContext.Current.Response.Redirect("home.aspx"); i have the
"Thread was being aborted" error. And if i use the
HttpContext.Current.Response.Redirect("home.aspx", false); overload i have
the "Authentication failed" error. So how can i redirect from a webmethod?
I have an aspx page with a WebMethod to redirect the user to another page.
The Default.aspx.cs is;
public partial class _Default : System.Web.UI.Page
{
[WebMethod]
public static void redirect_user()
{
HttpContext.Current.Response.Redirect("home.aspx");
}
}
and Default.aspx file;
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript">
function Button1_onclick()
{
PageMethods.redirect_user(redirectSuccess, redirectError);
}
function redirectSuccess(result)
{
alert(result);
}
function redirectError(error)
{
alert(error.get_message());
}
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="True" >
</asp:ScriptManager>
<div>
<input id="Button1" type="button" value="button" onclick="return
Button1_onclick()" />
</div>
</form>
</body>
</html>
When i use HttpContext.Current.Response.Redirect("home.aspx"); i have the
"Thread was being aborted" error. And if i use the
HttpContext.Current.Response.Redirect("home.aspx", false); overload i have
the "Authentication failed" error. So how can i redirect from a webmethod?