2

I need to do some validation before a page is served. If the validation is OK, the request should follow its normal flow; if not, it must redirect to another page and in that page the user will see something like an agreement, accept it and after that the pages should load as normal.

So, I have an application that have some pages on ASP Classic and others in ASP.NET. What I'm trying to do is to add an HttpModule to handle all the requests to do some logic to redirect, depending on the results, to another page.

So, in the IIS the ASP application is on top the others applications, and inside of that application I have other applications that are .NET.

I created an HttpModule to test it, registered the DLL and added the corresponding configuration on the web.config file that is at the ASP Application level.

This is the block I added to my web.config file

<system.web>
    <customErrors mode="Off"></customErrors>
    <httpModules>
        <add name="TestHttpModule" type="TestHttpModule.TestHttpModule, TestHttpModule,Version=1.0.0.0, Culture=neutral, PublicKeyToken=d76c51db0a9391cf"/>
    </httpModules>
</system.web>

The module just fires when an ASPX page is requested, but it doesn't when an ASP page is requested.

So is it possible to use a custom HttpModule for ASP pages or is not possible?

If not, do you know any other kind of approach for doing that?

The applications uses its App Pool in classic mode.

App Pool Configuration

Thanks in advance!

Orphen
  • 21
  • 4
  • 1
    Try adding your module to [`system.webServer`](https://learn.microsoft.com/en-us/iis/configuration/system.webserver/modules/add) instead. Those modules fire for all requests (unless you explicitly tell them not to). – vcsjones May 25 '18 at 19:46
  • I also have that configuration on my web.config but it didn't solve the problem :/ – Orphen May 28 '18 at 17:17

1 Answers1

2

The applications uses its App Pool in classic mode.

In classic mode, the ASP.NET pipeline is only activated for ASP.NET requests. So the module won't fire if the path ends with ".asp". But in integrated pipeline mode, it fires for every single request, including images, CSS files, and yes, classic ASP files.

So you will need to switch your implementation to use integrated pipeline mode and add your module to the config section named system.webserver instead of system.web. You may need to modify your module so it ignores requests for static resources (e.g. images and CSS) and only looks at requests that end with .aspx and .asp (and possibly .ashx or any other extensions that you use).

John Wu
  • 50,556
  • 8
  • 44
  • 80
  • It seems to be working but it doesn't :( Probably there is something else that I need to do in order to make it work. I changed the app pool from classic to integrated, but the HttpModule just goes through when I request aspx pages but not asp. I noticed it because I am trying to do a redirect from the page and it doesn't work – Orphen May 28 '18 at 17:09
  • I added a screenshot of my app pool on the question. I tried changing from classic to integrated – Orphen May 28 '18 at 17:15