How do I redirect or is it possible to redirect an aspx page from within an IHttpHandler? My code below give me error. Would really appreciate your pointers.
I already have critical work done and handled by some IHttpHandler classes. Interesting but puzzlingly, the error will go away if I commented out the first 3 lines as shown below. However, the supposedly redirected page still won't pop up. Any new suggestions will
be appreciated.
None
0 Points
7 Posts
Redirect aspx page from a IHttpHandler
Apr 21, 2006 08:13 AM|saihuan|LINK
Hi there,
How do I redirect or is it possible to redirect an aspx page from within an IHttpHandler? My code below give me error. Would really appreciate your pointers.
Thanks.
Sai
------------------------------------------
public class _Handler : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType =
"image/jpeg";context.Response.Cache.SetCacheability(
HttpCacheability.Public);context.Response.BufferOutput =
false;context.Response.Redirect(
"Report_page.aspx");}
}
None
0 Points
3 Posts
Re: Redirect aspx page from a IHttpHandler
Apr 21, 2006 02:32 PM|brentlee|LINK
Sai,
I use 'IHttpModule' rather but this may help.
Brent
using
System;using
System.Collections.Generic;using
System.Text;using
System.Web;namespace
Your.Namespace{
public sealed class CustomHttpModule : IHttpModule{
public void Init(HttpApplication app){
app.BeginRequest +=
new EventHandler(app_BeginRequest);app.EndRequest +=
new EventHandler(app_EndRequest);}
public void app_BeginRequest(Object sender, EventArgs e){
HttpApplication app = sender as HttpApplication;app.Context.Response.Redirect(
"YourUrl.com");}
public void app_EndRequest(Object sender, EventArgs e){
}
public void Dispose(){
}
}
}
None
0 Points
7 Posts
Re: Redirect aspx page from a IHttpHandler
Apr 22, 2006 05:53 AM|saihuan|LINK
Thanks but that won't work for me, Brent!
I already have critical work done and handled by some IHttpHandler classes. Interesting but puzzlingly, the error will go away if I commented out the first 3 lines as shown below. However, the supposedly redirected page still won't pop up. Any new suggestions will be appreciated.
Sai
--------------------------------
public class _Handler : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
// context.Response.ContentType =
"image/jpeg";// context.Response.Cache.SetCacheability(
HttpCacheability.Public);// context.Response.BufferOutput =
false;context.Response.Redirect( "Report_page.aspx");
}
}