How can i redirect from a webmethod?
How can i redirect from a webmethod?
am 21.01.2008 15:52:03 von 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" %>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Untitled Page
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?
RE: How can i redirect from a webmethod?
am 21.01.2008 17:43:01 von brucebarker
you can not redirect the client from a web method. the redirect only
redirects the method call. your web method should return the redirect url,
and javascript can do the redirect.
document.location.href = redirectUrl;
-- bruce (sqlwork.com)
"omer013" wrote:
> 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" %>
>
>
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
>
>
> Untitled Page
>
>
>
>
>
>
> 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?
>
>
RE: How can i redirect from a webmethod?
am 23.01.2008 01:57:07 von omer013
Is there any way to redirect the page on the server side?
"bruce barker" wrote:
> you can not redirect the client from a web method. the redirect only
> redirects the method call. your web method should return the redirect url,
> and javascript can do the redirect.
>
>
> document.location.href = redirectUrl;
>
>
> -- bruce (sqlwork.com)
>
>
> "omer013" wrote:
>
> > 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" %>
> >
> >
> > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> >
> >
> > Untitled Page
> >
> >
> >
> >
> >
> >
> > 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?
> >
> >
RE: How can i redirect from a webmethod?
am 23.01.2008 02:05:32 von omer013
Is there any way to redirect on the server side?
"bruce barker" wrote:
> you can not redirect the client from a web method. the redirect only
> redirects the method call. your web method should return the redirect url,
> and javascript can do the redirect.
>
>
> document.location.href = redirectUrl;
>
>
> -- bruce (sqlwork.com)
>
>
> "omer013" wrote:
>
> > 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" %>
> >
> >
> > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> >
> >
> > Untitled Page
> >
> >
> >
> >
> >
> >
> > 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?
> >
> >