在asp.net web.config中,如何配置httphandlers?
发布时间:2020-12-16 09:25:44 所属栏目:asp.Net 来源:网络整理
导读:情况是我希望所有文件类型都由指定的dll处理,除了’aspx’文件. 但我不知道如何编辑配置文件.如下: system.web httpHandlers add verb="*" path="*" type="My.Handler" / /httpHandlers/system.web 所有请求都将由My.Handler处理.如何正常访问aspx文件? 解
情况是我希望所有文件类型都由指定的dll处理,除了’aspx’文件.
但我不知道如何编辑配置文件.如下: <system.web> <httpHandlers> <add verb="*" path="*" type="My.Handler" /> </httpHandlers> </system.web> 所有请求都将由My.Handler处理.如何正常访问aspx文件? 解决方法
我有一个“解决方法”,但它有点“hacky”(我只在本地测试过)…
1.创建以下课程: public class PassThroughAspxHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { var pageInstance = PageParser.GetCompiledPageInstance(context.Request.AppRelativeCurrentExecutionFilePath,context.Request.PhysicalApplicationPath + context.Request.Path,context); pageInstance.ProcessRequest(context); } public bool IsReusable { get { return false; } } } 2.将条目添加到您的Web配置中: <system.webServer> <handlers> <add verb="*" path="*.aspx" name="PassThroughAspxHandler" type="YourNameSpaceHere.PassThroughAspxHandler"/> </handlers> </system.webServer> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- asp.net下的object元素中的类
- asp.net – 从aspx访问应用程序设置并添加连接文
- asp.net – 如何更改.ASPX自动格式化设置(Visual
- asp.net – 如何知道一个javascript文件是否已被
- asp.net-mvc-3 – MVC3非顺序索引和DefaultModel
- 在ASP.NET或ASP.NET MVC中生成管理界面
- asp.net-web-api – 为ASP.NET Web API应用程序生
- asp.net-mvc – LINQ用于检索多级关系数据的查询
- asp.net-mvc – 如何在asp.net中使用Captcha mvc
- asp.net-mvc – 如何在MVC3中的局部视图中渲染节
热点阅读