Click here to Skip to main content
16,005,048 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Empty gridview Pin
haleemasher17-Jul-09 0:25
haleemasher17-Jul-09 0:25 
GeneralRe: Empty gridview Pin
sekannak17-Jul-09 0:45
sekannak17-Jul-09 0:45 
QuestionRadio Button OnCheckedChanged() event is not called Pin
anada888616-Jul-09 18:35
anada888616-Jul-09 18:35 
AnswerRe: Radio Button OnCheckedChanged() event is not called Pin
Zafar A khan 17-Jul-09 0:22
professionalZafar A khan 17-Jul-09 0:22 
GeneralRe: Radio Button OnCheckedChanged() event is not called Pin
anada888617-Jul-09 0:26
anada888617-Jul-09 0:26 
AnswerRe: Radio Button OnCheckedChanged() event is not called Pin
sunil.n.cs17-Jul-09 23:44
sunil.n.cs17-Jul-09 23:44 
QuestionCreating interface that can read network traffic Pin
that_dude_tj16-Jul-09 13:08
that_dude_tj16-Jul-09 13:08 
QuestionDetermine requested URL when implementing IHttpModule Pin
Fernando A. Gomez F.16-Jul-09 11:06
Fernando A. Gomez F.16-Jul-09 11:06 
Hello all.

I'm working with a Web Application on IIS6 and ASP.NET 2.0, on a Windows 2003 server. This app has a class that implements the IHttpModule interface. So far, it overrides the HttpApplication.Context.Filter property to perform some filters on the data being streamed. The class looks something like the following:

public class PageCleanerStream
{
  // implement filter stuff here
}

public class PageCleanerHttpModule : IHttpModule
{
  PageCleanerHttpModule() { }
  public void Dispose() { }

  public void Init(HttpApplication context)
  {
    context.PostRequestHandlerExecute += new EventHandler(
      delegate(object sender, EventArgs args)
      {
        if (sender is HttpApplication)
        {
          using (HttpApplication app = sender as HttpApplication)
          {
            if (app.Context.CurrentHandler is Page)
              app.Response.Filter = new PageCleanerStream(app.Response.Filter);	
          }
        }
      }
    );
  }
}


Of course, I have my web.config properly configured and so far everything works as expected: the filter performed by PageCleanerStream does its work well.

Now, I have a new requirement stating that such filter should not be performed on a particular page (i.e. when "somepage.aspx" is requested the filter should not apply. So, I thought it was only a matter of getting the URL of the page being requested and see if it matches "somepage.aspx".

However, I haven't found a way of getting such URL. So far, I've tried three approaches.

1. Cast app.Context.CurrentHandler to a Page, and if not null, then check the Url property. Something like:
Page page = app.Context.CurrentHandler as Page;
if (page.Request.Url.GetLeftPart(UriPartial.Path).IndexOf("somepage.aspx") < 0)
  app.Response.Filter = new PageCleanerStream(app.Response.Filter);	

This fails because at the time the event is invoked the page.Request object is unavailable.

2. Get the URI property from HTTP headers, as:
if ((app.Response.Headers["URI"]).IndexOf("somepage.aspx") < 0)
  app.Response.Filter = new PageCleanerStream(app.Response.Filter);

This approach fails too since it throws a PlatformNotSupportedException, saying that such property requires IIS 7 and .NET Framework 3.0, and at the time, changing the environment is not an option.

3. Finally, I tried calling the HttpResponse.RedirectLocation, yet it returns a null.

So now I'm out of ideas, other than ask for help and keep googling to see if I can find something useful. So... under this scenario, does someone know how could I determine the page's URL being
requested? I'm opened to new approaches as well.

Any clue will be really appreciated.

Thanks in advance.



Stupidity is an International Association - Enrique Jardiel Poncela

AnswerRe: Determine requested URL when implementing IHttpModule Pin
evald8023-Jan-10 6:15
evald8023-Jan-10 6:15 
GeneralRe: Determine requested URL when implementing IHttpModule Pin
Fernando A. Gomez F.23-Jan-10 8:41
Fernando A. Gomez F.23-Jan-10 8:41 
GeneralRe: Determine requested URL when implementing IHttpModule Pin
evald8024-Jan-10 0:15
evald8024-Jan-10 0:15 
QuestionGridView...AutoPostback and SelectedIndexChanged Issue Pin
PDTUM16-Jul-09 7:58
PDTUM16-Jul-09 7:58 
QuestionGridview question Pin
Priya Prk16-Jul-09 6:29
Priya Prk16-Jul-09 6:29 
AnswerRe: Gridview question Pin
Christian Graus16-Jul-09 7:03
protectorChristian Graus16-Jul-09 7:03 
GeneralRe: Gridview question Pin
Priya Prk16-Jul-09 8:27
Priya Prk16-Jul-09 8:27 
GeneralRe: Gridview question Pin
N a v a n e e t h16-Jul-09 8:41
N a v a n e e t h16-Jul-09 8:41 
GeneralRe: Gridview question Pin
Abhijit Jana16-Jul-09 9:42
professionalAbhijit Jana16-Jul-09 9:42 
GeneralRe: Gridview question Pin
Priya Prk16-Jul-09 12:30
Priya Prk16-Jul-09 12:30 
QuestionCalling a Win32 dll from ASP.NET. Pin
ashwath197916-Jul-09 5:54
ashwath197916-Jul-09 5:54 
AnswerRe: Calling a Win32 dll from ASP.NET. Pin
Abhijit Jana16-Jul-09 5:57
professionalAbhijit Jana16-Jul-09 5:57 
GeneralRe: Calling a Win32 dll from ASP.NET. Pin
ashwath197916-Jul-09 6:29
ashwath197916-Jul-09 6:29 
GeneralRe: Calling a Win32 dll from ASP.NET. Pin
Christian Graus16-Jul-09 7:01
protectorChristian Graus16-Jul-09 7:01 
AnswerRe: Calling a Win32 dll from ASP.NET. Pin
Christian Graus16-Jul-09 7:00
protectorChristian Graus16-Jul-09 7:00 
QuestionCan’t get GridView RowIndex. Pin
enipla16-Jul-09 5:08
enipla16-Jul-09 5:08 
AnswerRe: Can’t get GridView RowIndex. Pin
Abhijit Jana16-Jul-09 5:53
professionalAbhijit Jana16-Jul-09 5:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.