Last post Dec 05, 2011 10:53 PM by rstrahl
Sep 19, 2011 10:03 AM|kollisp|LINK
I have written a HTTPModule extending IHTTPModule. Can this HTTPModule be installed for a website instead of a virtual directory in IIS.
Like for the whole DefaultWebSite.
Sep 19, 2011 11:01 AM|Rajganesh|LINK
Register your HTTPModule in the machine.config file. Below link may help you.
Sep 19, 2011 11:40 AM|kollisp|LINK
Thanks for the reply.
I have added my custom HTTPModule in web.config file for the web site.
<httpModules> <add type="CustomModule.CusotmModule" name="CustomModule"/> </httpModules>
When I try to access a virtual directory under the web site its trying to load CustomModule.CustomModule.
And throwing an error
Exception information: Exception type: ConfigurationErrorsException Exception message: Could not load type 'CustomModule.CusotmModule'. (c:\inetpub\wwwroot\web.config line 5) (c:\inetpub\wwwroot\web.config line 5)
Sep 19, 2011 11:51 AM|Rajganesh|LINK
Have you added the reference to the CustomModule.CusotmModule in your website?
Sep 19, 2011 11:59 AM|kollisp|LINK
Sorry I didnt understand about adding reference.
How to add the reference.
Sep 19, 2011 12:08 PM|Rajganesh|LINK
Is the code for HTTPModule is available under the App_Code directory of the website or is it an external dll?
If it is an external dll file you need to add the reference to the dll file in your website.
Sep 19, 2011 12:15 PM|kollisp|LINK
It is an external dll.
Sorry for the following question I am new to this IIS and HTTPModules
How to add reference to the dll in the website.
My HTTPModule is also dependent on other dlls.
Sep 19, 2011 12:19 PM|Rajganesh|LINK
As it is an external dll, you need to add the reference to the dll to the website.
Check the below link to learn more about adding reference.
Sep 19, 2011 01:04 PM|kollisp|LINK
May be I was not clear in explaining my issue.
Links you have provided are showing how to add references of a external dll to asp.net applications I create in visual studiol
Here is the issue I am facing.
Under IIS WebSites we have Default Web Site. I have created External Web Site under WebSites with a different IP.
There are virtual directories under both the Default and External web site. I have to apply a custom HTTPModule to only Default Web Site.
If the user access any virtual directory under Default web site the modules kicks in.
If the user access any virtual directory under External web site module shoud not do anything.
So I thought may be this HTTPModule can be configured at the WebSite level instead for each virtual directory.
I created a config file under Default Web Site root folder where I have provided configuration for the HTTPModule.
When I a hit virutal directory URL from browser its trying to load Module but failing with the exception I have sent earlier.
Sorry for the confusion created.
Sep 20, 2011 03:19 AM|Rajganesh|LINK
Well, I understood your problem now. As this HTTPModule is going to be common for all the virtual directories, I think you need to add your HTTPModule dll to the GAC.
Can you try adding your dll to GAC, so that it would be referenced in all your virtual directories.
Nov 22, 2011 05:22 AM|venubabum.net|LINK
i copied dll in GAC,after that registered the dll in web.config but it is not working.
<add name="modulename" type="httphandler1.handlerclass,httphandler1, Version=184.108.40.206, Culture=neutral, PublicKeyToken=4f62e909d171324d"/>
it is showing error
Could not load file or assembly 'httphandler1, Version=220.127.116.11, Culture=neutral, PublicKeyToken=4f62e909d171324d'
or one of its dependencies. The system cannot find the file specified. (D:\WebSite17\web.config line 75)
Dec 05, 2011 10:53 PM|rstrahl|LINK
Just for clarification:
When you add a module to the root of your Web site, it's visible to all child virtual directories.
As such you have to make sure the module is available to run in all child virtuals (ie. either in the BIN folder or the GAC)
You can explicitly remove the module from child virtuals with the <remove> key in the handlers section if you don't want it to fire in the child virtual.
+++ Rick ---