HTTPModule not called for non-existant pages

Discussion in 'ASP .Net' started by Guest, Nov 25, 2004.

  1. Guest

    Guest Guest

    I have earlier used an HttpModule that did URL rewrites on the BeginRequest
    event.

    Now I am trying to use the same module in a different application on a new
    and upgraded machine (winxp sp2).

    The Module is registered via Web.config. The registration is OK. When asking
    for an existing .aspx page, the eventhandler is called as it should.

    HOWEVER - if the request url is for a non-existant file, I get a 404 - file
    not found error. The module is never called.
    And if the url is only a path name e.g. http://server/some/path - and that
    path does not allow browsing, then I get Directory Listing Denied error. If
    browsing is allowed, I see the contents. The HttpModule BeginRequest method
    is *not* called in these instances.

    Any clues on what I may be missing here? or is this a change done through
    sp2?

    Thank you for your time!

    -Inge
    Guest, Nov 25, 2004
    #1
    1. Advertising

  2. Inge,
    To do some work based on the requested page whether or not it exists, do
    the work using the AuthorizeRequest event. I use this event to do URL
    rewriting. Of course, there are still some restrictions. If you have the
    default page set to default.aspx, and there is no default.aspx, then the
    ASP.NET ISAPI won't ever be called from IIS. If you have a default page,
    IIS handles translating a request to /subFolder/ into
    /subFolder/default.aspx. Then the requested resource ends in .aspx and the
    ASP.NET ISAPI takes over and will execute you code, so a situation may still
    exist where IIS never calls ASP.NET.

    Best regards,
    Jeffrey Palermo

    <> wrote in message
    news:...
    > I have earlier used an HttpModule that did URL rewrites on the

    BeginRequest
    > event.
    >
    > Now I am trying to use the same module in a different application on a new
    > and upgraded machine (winxp sp2).
    >
    > The Module is registered via Web.config. The registration is OK. When

    asking
    > for an existing .aspx page, the eventhandler is called as it should.
    >
    > HOWEVER - if the request url is for a non-existant file, I get a 404 -

    file
    > not found error. The module is never called.
    > And if the url is only a path name e.g. http://server/some/path - and that
    > path does not allow browsing, then I get Directory Listing Denied error.

    If
    > browsing is allowed, I see the contents. The HttpModule BeginRequest

    method
    > is *not* called in these instances.
    >
    > Any clues on what I may be missing here? or is this a change done through
    > sp2?
    >
    > Thank you for your time!
    >
    > -Inge
    >
    >
    Jeffrey Palermo [MCP], Nov 26, 2004
    #2
    1. Advertising

  3. Guest

    Guest Guest

    Thank you for the reply.

    If my memory is not failling me, I have had the handler be called for
    nonexistant files, and also for folder names - without changing the default
    document.

    But what you say seems to be working - at least insofar as the HttpModule
    being triggered when the request is for any kind of .aspx.

    However, I have moved the default.aspx-file to the top of the
    default-documents list (which *is* enabled). the handler is still not
    executed if I only request http://myserver/mywebsite

    If I put in a file of that name, it works (as expected) - but this requires
    a default.aspx in every subfolder, in order to get the httpmodule to process
    BeginRequest.

    This is *not* the behaviour I experienced this spring :/

    So I am still wondering that something might have changed e.g. with the
    introduction of WinXP sp2

    -Inge




    "Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
    message news:...
    > Inge,
    > To do some work based on the requested page whether or not it exists,
    > do
    > the work using the AuthorizeRequest event. I use this event to do URL
    > rewriting. Of course, there are still some restrictions. If you have the
    > default page set to default.aspx, and there is no default.aspx, then the
    > ASP.NET ISAPI won't ever be called from IIS. If you have a default page,
    > IIS handles translating a request to /subFolder/ into
    > /subFolder/default.aspx. Then the requested resource ends in .aspx and
    > the
    > ASP.NET ISAPI takes over and will execute you code, so a situation may
    > still
    > exist where IIS never calls ASP.NET.
    >
    > Best regards,
    > Jeffrey Palermo
    >
    > <> wrote in message
    > news:...
    >> I have earlier used an HttpModule that did URL rewrites on the

    > BeginRequest
    >> event.
    >>
    >> Now I am trying to use the same module in a different application on a
    >> new
    >> and upgraded machine (winxp sp2).
    >>
    >> The Module is registered via Web.config. The registration is OK. When

    > asking
    >> for an existing .aspx page, the eventhandler is called as it should.
    >>
    >> HOWEVER - if the request url is for a non-existant file, I get a 404 -

    > file
    >> not found error. The module is never called.
    >> And if the url is only a path name e.g. http://server/some/path - and
    >> that
    >> path does not allow browsing, then I get Directory Listing Denied error.

    > If
    >> browsing is allowed, I see the contents. The HttpModule BeginRequest

    > method
    >> is *not* called in these instances.
    >>
    >> Any clues on what I may be missing here? or is this a change done through
    >> sp2?
    >>
    >> Thank you for your time!
    >>
    >> -Inge
    >>
    >>

    >
    >
    Guest, Nov 26, 2004
    #3
  4. Guest

    Guest Guest

    Behaviour is definitely different

    After looking at the behaviour of the old system running the code, the
    behaviour is definitely different.

    MSFT, can you look into this - it seems that there is a change in how
    HttpModules are processed.

    Old behaviour (WinXP, and W2K server w/IIS 5.0):
    -registered an httpmodule in web.config
    -the module implements BeginRequest
    -the module rewrites any folder-only URLs (i.e. ending in / or without
    an extension) to somepage.aspx
    -default page for the virtual directory is (probably) set to
    default.aspx

    If I open http://myserver/, it is rewritten to http://myserver/somepage.aspx
    If I open http://myserver/somesubdir, it is rewritten to
    http://myserver/somesubdir/somepage.aspx
    If I open http://myserver/someNonExistantSubDir, it is rewritten to
    http://myserver/someNonExistantSubDir/somepage.aspx

    This happens although there is no default.aspx page in any directories.

    New behaviour (WinXP Sp2 IIS 5.1):
    -registered an httpmodule in web.config
    -the module implements BeginRequest
    -the module rewrites any folder-only URLs (i.e. ending in / or without
    an extension) to somepage.aspx
    -default page for the virtual directory is set to default.aspx (or not,
    behaviour is identical)

    If I open http://myserver/, I get directory listing denied. id listing is
    allowed, I get the contents. BeginRequest never called.
    If I open http://myserver/somesubdir, I get directory listing denied.
    BeginRequest never called.
    If I open http://myserver/someNonExistantSubDir, I get 404 not found.
    BeginRequest never called.

    In this case, anything ending in .aspx is forwarded to the httpmodule - but
    this is definitely different from my previously experienced behaviour.

    So I am still wondering exactly what has happened, why - and if there is any
    way to continue to rewrite non-.aspx (etc) urls in asp,net

    Thank you!

    -Inge


    <> wrote in message
    news:...
    > Thank you for the reply.
    >
    > If my memory is not failling me, I have had the handler be called for
    > nonexistant files, and also for folder names - without changing the
    > default document.
    >
    > But what you say seems to be working - at least insofar as the HttpModule
    > being triggered when the request is for any kind of .aspx.
    >
    > However, I have moved the default.aspx-file to the top of the
    > default-documents list (which *is* enabled). the handler is still not
    > executed if I only request http://myserver/mywebsite
    >
    > If I put in a file of that name, it works (as expected) - but this
    > requires a default.aspx in every subfolder, in order to get the httpmodule
    > to process BeginRequest.
    >
    > This is *not* the behaviour I experienced this spring :/
    >
    > So I am still wondering that something might have changed e.g. with the
    > introduction of WinXP sp2
    >
    > -Inge
    >
    >
    >
    >
    > "Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote
    > in message news:...
    >> Inge,
    >> To do some work based on the requested page whether or not it exists,
    >> do
    >> the work using the AuthorizeRequest event. I use this event to do URL
    >> rewriting. Of course, there are still some restrictions. If you have
    >> the
    >> default page set to default.aspx, and there is no default.aspx, then the
    >> ASP.NET ISAPI won't ever be called from IIS. If you have a default page,
    >> IIS handles translating a request to /subFolder/ into
    >> /subFolder/default.aspx. Then the requested resource ends in .aspx and
    >> the
    >> ASP.NET ISAPI takes over and will execute you code, so a situation may
    >> still
    >> exist where IIS never calls ASP.NET.
    >>
    >> Best regards,
    >> Jeffrey Palermo
    >>
    >> <> wrote in message
    >> news:...
    >>> I have earlier used an HttpModule that did URL rewrites on the

    >> BeginRequest
    >>> event.
    >>>
    >>> Now I am trying to use the same module in a different application on a
    >>> new
    >>> and upgraded machine (winxp sp2).
    >>>
    >>> The Module is registered via Web.config. The registration is OK. When

    >> asking
    >>> for an existing .aspx page, the eventhandler is called as it should.
    >>>
    >>> HOWEVER - if the request url is for a non-existant file, I get a 404 -

    >> file
    >>> not found error. The module is never called.
    >>> And if the url is only a path name e.g. http://server/some/path - and
    >>> that
    >>> path does not allow browsing, then I get Directory Listing Denied error.

    >> If
    >>> browsing is allowed, I see the contents. The HttpModule BeginRequest

    >> method
    >>> is *not* called in these instances.
    >>>
    >>> Any clues on what I may be missing here? or is this a change done
    >>> through
    >>> sp2?
    >>>
    >>> Thank you for your time!
    >>>
    >>> -Inge
    >>>
    >>>

    >>
    >>

    >
    >
    Guest, Nov 26, 2004
    #4
  5. Guest

    Guest Guest

    Confusion solved - new issue with IIS on WinXP

    There was one (minor detail *cough* ) that has slipped my memory during the
    months since I last did this -
    I added an extension mapping for * to use the asp.net ISAPI filter. Thus I
    was able to get my httpmodule to execute even though the document did not
    exist etc..
    Now, this is not possible on w2k3 server - but it can be done in a dedicated
    box below - Wildcard Application Maps.

    But in my current WinXP, I can't map * - neither is there a "Wildcard
    Application maps".

    It does however seem to work fine by specifying a map for ".*" - this is
    accepted, and the httpModule is called.

    So I guess there is no real change in behaviour (just a slight change in GUI
    on the different OS's).

    This also means that I just solved my problem - and that Jeffery is right in
    stating that this shouldn't normally work. It works because I tell IIS to
    shovel everything thrown at it, straight to asp.net for handling. This seems
    to work, without hampering such things as serving of static content - but I
    would be interested in hearing others opinions on sideeffects caused by this
    kind of mapping :)

    cheerio!

    -Inge


    <> wrote in message
    news:...
    > After looking at the behaviour of the old system running the code, the
    > behaviour is definitely different.
    >
    > MSFT, can you look into this - it seems that there is a change in how
    > HttpModules are processed.
    >
    > Old behaviour (WinXP, and W2K server w/IIS 5.0):
    > -registered an httpmodule in web.config
    > -the module implements BeginRequest
    > -the module rewrites any folder-only URLs (i.e. ending in / or without
    > an extension) to somepage.aspx
    > -default page for the virtual directory is (probably) set to
    > default.aspx
    >
    > If I open http://myserver/, it is rewritten to
    > http://myserver/somepage.aspx
    > If I open http://myserver/somesubdir, it is rewritten to
    > http://myserver/somesubdir/somepage.aspx
    > If I open http://myserver/someNonExistantSubDir, it is rewritten to
    > http://myserver/someNonExistantSubDir/somepage.aspx
    >
    > This happens although there is no default.aspx page in any directories.
    >
    > New behaviour (WinXP Sp2 IIS 5.1):
    > -registered an httpmodule in web.config
    > -the module implements BeginRequest
    > -the module rewrites any folder-only URLs (i.e. ending in / or without
    > an extension) to somepage.aspx
    > -default page for the virtual directory is set to default.aspx (or not,
    > behaviour is identical)
    >
    > If I open http://myserver/, I get directory listing denied. id listing is
    > allowed, I get the contents. BeginRequest never called.
    > If I open http://myserver/somesubdir, I get directory listing denied.
    > BeginRequest never called.
    > If I open http://myserver/someNonExistantSubDir, I get 404 not found.
    > BeginRequest never called.
    >
    > In this case, anything ending in .aspx is forwarded to the httpmodule -
    > but this is definitely different from my previously experienced behaviour.
    >
    > So I am still wondering exactly what has happened, why - and if there is
    > any way to continue to rewrite non-.aspx (etc) urls in asp,net
    >
    > Thank you!
    >
    > -Inge
    >
    >
    > <> wrote in message
    > news:...
    >> Thank you for the reply.
    >>
    >> If my memory is not failling me, I have had the handler be called for
    >> nonexistant files, and also for folder names - without changing the
    >> default document.
    >>
    >> But what you say seems to be working - at least insofar as the HttpModule
    >> being triggered when the request is for any kind of .aspx.
    >>
    >> However, I have moved the default.aspx-file to the top of the
    >> default-documents list (which *is* enabled). the handler is still not
    >> executed if I only request http://myserver/mywebsite
    >>
    >> If I put in a file of that name, it works (as expected) - but this
    >> requires a default.aspx in every subfolder, in order to get the
    >> httpmodule to process BeginRequest.
    >>
    >> This is *not* the behaviour I experienced this spring :/
    >>
    >> So I am still wondering that something might have changed e.g. with the
    >> introduction of WinXP sp2
    >>
    >> -Inge
    >>
    >>
    >>
    >>
    >> "Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote
    >> in message news:...
    >>> Inge,
    >>> To do some work based on the requested page whether or not it exists,
    >>> do
    >>> the work using the AuthorizeRequest event. I use this event to do URL
    >>> rewriting. Of course, there are still some restrictions. If you have
    >>> the
    >>> default page set to default.aspx, and there is no default.aspx, then the
    >>> ASP.NET ISAPI won't ever be called from IIS. If you have a default
    >>> page,
    >>> IIS handles translating a request to /subFolder/ into
    >>> /subFolder/default.aspx. Then the requested resource ends in .aspx and
    >>> the
    >>> ASP.NET ISAPI takes over and will execute you code, so a situation may
    >>> still
    >>> exist where IIS never calls ASP.NET.
    >>>
    >>> Best regards,
    >>> Jeffrey Palermo
    >>>
    >>> <> wrote in message
    >>> news:...
    >>>> I have earlier used an HttpModule that did URL rewrites on the
    >>> BeginRequest
    >>>> event.
    >>>>
    >>>> Now I am trying to use the same module in a different application on a
    >>>> new
    >>>> and upgraded machine (winxp sp2).
    >>>>
    >>>> The Module is registered via Web.config. The registration is OK. When
    >>> asking
    >>>> for an existing .aspx page, the eventhandler is called as it should.
    >>>>
    >>>> HOWEVER - if the request url is for a non-existant file, I get a 404 -
    >>> file
    >>>> not found error. The module is never called.
    >>>> And if the url is only a path name e.g. http://server/some/path - and
    >>>> that
    >>>> path does not allow browsing, then I get Directory Listing Denied
    >>>> error.
    >>> If
    >>>> browsing is allowed, I see the contents. The HttpModule BeginRequest
    >>> method
    >>>> is *not* called in these instances.
    >>>>
    >>>> Any clues on what I may be missing here? or is this a change done
    >>>> through
    >>>> sp2?
    >>>>
    >>>> Thank you for your time!
    >>>>
    >>>> -Inge
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Guest, Nov 26, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Segall
    Replies:
    6
    Views:
    6,376
    GaryM
    Nov 10, 2003
  2. Bac2Day1

    Adding HTTPMODULE for certain pages

    Bac2Day1, Apr 10, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    419
    Charles Zhang
    Apr 11, 2007
  3. vsoler
    Replies:
    6
    Views:
    484
    Mark Tolonen
    Aug 25, 2010
  4. Larry
    Replies:
    0
    Views:
    185
    Larry
    May 12, 2004
  5. charlie_M
    Replies:
    6
    Views:
    90
    Thomas 'PointedEars' Lahn
    May 19, 2005
Loading...

Share This Page