-1

I would like to have my code for an HttpModule somewhere else than in the App_code folder, is that possible?

EDIT: For now, i have my module in a class file in the App_code folder of my web application. I'm successfuly registering it with this line in my web.config

<httpModules>
  <add name="myModule" type="myModule,App_code"/>
</httpModules>

What i would like to do is being able to put my class file somewhere else than in the Ape_code folder. Something like :

<httpModules>
  <add name="myModule" type="myModule, myOtherFolder"/>
</httpModules>
Shadowxvii
  • 1,080
  • 2
  • 12
  • 31
  • Please start with [google/documentation](http://msdn.microsoft.com/en-us/library/ms227673.aspx) and come back when you have a more specific question. – Kirk Woll Apr 12 '12 at 19:19
  • First result on Google for your title http://msdn.microsoft.com/en-us/library/ms227673.aspx – IrishChieftain Apr 12 '12 at 19:20
  • You haven't indicated what you've tried or what information you've reviewed. – TLS Apr 12 '12 at 19:23
  • Ho why thank you for the link you gave me (twice). I guess i never saw it (every single google search i did myself had this link at some point), and it doesn't help me. I'll add more details as to why it doen'st help. – Shadowxvii Apr 12 '12 at 19:35
  • You'll want to do some searching on the proper use of "namespaces" so that you can reference the code correctly in the config file. – TLS Apr 12 '12 at 20:03
  • I followed that namespace lead, and tried while putting my httpmodule class inside the said namespace. Still no luck – Shadowxvii Apr 12 '12 at 20:44

2 Answers2

3

So, finaly, here's how I solved my problem. I found that to register an HttpModule, you have to use the foollowing syntax.

<httpModules>
  <add name="MyModuleName" type="MyApplicationNamespace.MyModuleNamespace.MyModuleClassName, MyApplicationAssemblyName"/>
</httpModules>

Notes:

  • MyModuleName is not restrictive, it is used by the application to reference the module
  • Since MyApplicationName and MyApplicationAssemblyName is often the same (it is in my case), it is probable that the syntax above isn't totaly acurate.

Hope this can help someone else.

Shadowxvii
  • 1,080
  • 2
  • 12
  • 31
0

Yes, it is possible. You'll have to switch from "Web Site Project" to "Web Application Project." Here are a few resources to get you started:

Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio

Web Application Projects versus Web Site Projects

Introduction to Web Application Projects

ASP.NET: Web Site or Web Application?

Community
  • 1
  • 1
TLS
  • 3,090
  • 2
  • 25
  • 33
  • I believe i'm already working with a web application project. – Shadowxvii Apr 12 '12 at 19:33
  • Web Application Projects don't have an App_Code folder by default. It was either added manually by somebody or the project was converted from a Web Site Project. Either way, the resources referenced here should shed some light on what you want to do. – TLS Apr 12 '12 at 19:36
  • I added the folder myself because in the exemples i read, it was where i should put my httpModule class file. What i want is being able to put the class file somewhere else. – Shadowxvii Apr 12 '12 at 19:39