I am trying to create an ISAPI filter using VB.NET. (In IIS, right click a
website, click properties, click the "ISAPI Filters Tab).

Maybe I am barking up the wrong tree but this is what I want to do.

I want to filter ALL requests to a website (including images, pdf, word
docs, EVERYTHING) and then perform authintication on it.

From what I have found, IHTTPModule is the way I want to go. I do not want
to create an ISAPI Extension because I do not want to map extensions to the
aspnet_isapi.dll because I do not know what extensions might exist.

I have found a few example of the IHTTPModule but none tell me everything
that I need to know like What project to use (Web Application, Web Service,
etc...)

If someone could point me to a good example or even some source code that
would be great.

I downloaded an ISAPI filter from Microsoft call ed URLScan that was
supposed to include the source code but I could not find the source code
after installing.

Any help would be greatly appreciated.

Re: VB.NET ISAPI Filer / IHTTPModule by David

David
Wed Feb 22 02:41:09 CST 2006

Search my blog for sample code. Also search my blog for info clarify ISAPI
Extension, ISAPI Filter, IHttpModule, and IHttpHandler and how they differ
and relate...

Clarifying the terminology...

IHttpModule only applies to content handled by aspnet_isapi.dll
- You can *-scriptmap aspnet_isapi.dll to apply it to all URL extensions
- Prior to IIS6 this only works for static file types (images, pdf, word)
but not dynamic file types (ASP, PHP, Perl pages)
- IIS6 with ASP.Net 2.0 allow aspnet_isapi.dll to filter and apply
IHttpModule transformations to a request but also hand requests back to IIS
for actual processing

ISAPI Filter filters requests in the fashion that you want by default and
can perform authentication on such requests, but you must write it in C/C++
(or Delphi). You cannot write ISAPI Filter with .Net nor Java.

Can you point me to the URL that says that the source code to URLScan was
supposed to be included in a download. Microsoft publishes plenty of source
code samples for ISAPI Extension/Filter for free in the IIS Platform SDK.

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm

--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//

"John Wycoff" <John Wycoff@discussions.microsoft.com> wrote in message
news:A8350198-44F1-4BAD-A518-E5D2E408DE09@microsoft.com...
>I am trying to create an ISAPI filter using VB.NET. (In IIS, right click a
> website, click properties, click the "ISAPI Filters Tab).
>
> Maybe I am barking up the wrong tree but this is what I want to do.
>
> I want to filter ALL requests to a website (including images, pdf, word
> docs, EVERYTHING) and then perform authintication on it.
>
> From what I have found, IHTTPModule is the way I want to go. I do not want
> to create an ISAPI Extension because I do not want to map extensions to
> the
> aspnet_isapi.dll because I do not know what extensions might exist.
>
> I have found a few example of the IHTTPModule but none tell me everything
> that I need to know like What project to use (Web Application, Web
> Service,
> etc...)
>
> If someone could point me to a good example or even some source code that
> would be great.
>
> I downloaded an ISAPI filter from Microsoft call ed URLScan that was
> supposed to include the source code but I could not find the source code
> after installing.
>
> Any help would be greatly appreciated.



Re: VB.NET ISAPI Filer / IHTTPModule by JohnWycoff

JohnWycoff
Wed Feb 22 09:51:29 CST 2006

David, thanks for the info.

But in a nut shell is it possible to filter all requests that come into iis
including images, pdf, etc... via a .NET language?

The link to the URLScan is below. Click the link then scroll down until you
find URLScan.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/eb9af0bf-2d93-4c38-aad5-b93670167e4d.asp

Re: VB.NET ISAPI Filer / IHTTPModule by David

David
Wed Feb 22 19:04:41 CST 2006

To filter all requests with a .Net language requires:
1. IIS6 and ASP.Net 2.0
2. aspnet_isapi.dll configured as a wildcard application mapping that is
effectively applied to all URLs of interest
3. DefaultHttpHandler (or an class extended from DefaultHttpHandler) that
handles all requests to go back to IIS (in other words, .Net code gets to
first filter the request, and IIS gets to process the request
appropriately - this allows static files like images, pdf, etc be handled by
the more efficient IIS Static File Handler).

Search my blog for more details on this.

--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//

"John Wycoff" <JohnWycoff@discussions.microsoft.com> wrote in message
news:5E4FBC84-F8EA-4260-8E4A-BBCB63EDC1D2@microsoft.com...
> David, thanks for the info.
>
> But in a nut shell is it possible to filter all requests that come into
> iis
> including images, pdf, etc... via a .NET language?
>
> The link to the URLScan is below. Click the link then scroll down until
> you
> find URLScan.
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/eb9af0bf-2d93-4c38-aad5-b93670167e4d.asp



Re: VB.NET ISAPI Filer / IHTTPModule by JohnWycoff

JohnWycoff
Wed Feb 22 21:29:26 CST 2006

David,

Thanks for all of your help, I think I got this working in IIS 5.0

I dont remember wildcards working before in IIS 5 but it is now. I then
added the handler to the web.config file at at first glance it seems to be
working. I am going to bed now but I will test later and keep you updated.

Thanks Again, Great Help!

Re: VB.NET ISAPI Filer / IHTTPModule by David

David
Wed Feb 22 21:47:28 CST 2006

The same steps "work" on IIS5 but is not fully functional. It only works for
ASP.Net content and static file (like doc, pdf, txt).

Prior to IIS6+ASP.Net2.0, you cannot do this for dynamic file (like .asp,
.php, .pl). This is because IIS6 and ASP.Net 2.0 allows ASP.Net to hand
processing of dynamic file back to IIS whereas all other versions cannot
hand the request back to IIS (thus you can only apply .Net code to requests
that ASP.Net would otherwise handle already -- like ASP.Net pages and static
files).

--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//

"John Wycoff" <JohnWycoff@discussions.microsoft.com> wrote in message
news:C6B68790-6095-4763-8B3D-6CE3F7BF406D@microsoft.com...
> David,
>
> Thanks for all of your help, I think I got this working in IIS 5.0
>
> I dont remember wildcards working before in IIS 5 but it is now. I then
> added the handler to the web.config file at at first glance it seems to be
> working. I am going to bed now but I will test later and keep you updated.
>
> Thanks Again, Great Help!



Re: VB.NET ISAPI Filer / IHTTPModule by JohnWycoff

JohnWycoff
Thu Feb 23 19:27:08 CST 2006

That makes sense. Luckily I will not be using any .asp files in this project
so it will work fine for me.

The only problem I am having now is that every file gets processed by my
handler then stops. For example my ProcessRequest routine response.writes
some test text and that is it. When you load the page (or file) it says
"Hello World" and that is it. the asp.net worker process does not load the
rest of the page.

I have looked at several examples on this topic and cannot find any mention
of any settings or calls that have to be made to make .net continue
processing.

What am I doing wrong?

John Wycoff