在web.config中注册的HttpModules [英] registering httpModules in web.config

查看:466
本文介绍了在web.config中注册的HttpModules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想注册在web.config文件的自定义的HttpHandler。 MSDN的 示例显示了一个条目是注释掉...嗯不工作这么好。当我取消我收到无法加载文件或程序集HttpModule.cs或它的一个依赖。该系统找不到指定的文件。错误。文件名是HttpModule.cs和类名是MyHttpModule。有没有明确的命名空间呢。

I am trying to register a custom HttpHandler in the web.config file. MSDN's example shows an entry that is commented out...um which doesn't work so well. When I uncomment I receive a Could not load file or assembly 'HttpModule.cs' or one of its dependencies. The system cannot find the file specified. error. The file name is HttpModule.cs and the class name is MyHttpModule. There is no explicit namespace yet.

<httpModules>
     <add name="MyHttpModule" type="MyHttpModule, HttpModule" />
<httpModules>

我确信我俯瞰明显。我需要的地方指定文件路径?先谢谢了。

I am sure I am overlooking the obvious. Do I need to specify the file path somewhere? Thanks in advance.

推荐答案

我还在学习很多术语,并需要它阐明了我。在任何情况下,你需要的一样的...

I am still learning much of the terminology and needed it spelled out for me. In case any of you need the same...

作为一个例子,如果:


  • 的基类名称和项目名称是测试网站

  • 的命名空间我的课是为 BusinessLogic

  • 类名为 PageAuthorization

  • The base class name and project name is TestSite
  • The namespace my class is in is BusinessLogic
  • The class name is PageAuthorization

在Web.config文件...

in the Web.config file...

<configuration> 
 <system.web> 
  <httpModules> 
   <add type= "BusinessLogic.PageAuthorization, TestSite" name="PageAuthorization" /> 
  </httpModules> 
 </system.web> 
</configuration>

在我来说,我不得不以纪念我与 IHttpModule的类。类的定义将如下:

In my case I had to mark my class with IHttpModule. The definition of the class would look like:

public class PageAuthorization : IHttpModule

这篇关于在web.config中注册的HttpModules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆