asp.net – Mono和IHttpHandler
我想使用IHttpHandler方法在.Net-Project中使用XSP或更好的mod_mono.
我有以下课程(非常简单: public class Class1 : IHttpHandler { public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { var result = "<h1>Yeah</h1>"; var bytes = Encoding.UTF8.GetBytes(result); context.Response.Write(result); } } 以及web.config <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers accessPolicy="Read,Execute,Script"> <add name="Class" path="*" verb="*" type="IISHost.Class1" resourceType="Unspecified" preCondition="integratedMode" /> </handlers> </system.webServer> <system.web> <compilation defaultLanguage="c#" /> </system.web> </configuration> 它在IIS中完美运行. http://127.0.0.1/test/kfdlsa返回’是’ 在Apache的XSP或mod_mono中,我可以创建一个index.aspx,它根据.Net-Framework完美地解析和执行,但似乎处理程序不包含在mod_mono-Framework中. 使用IHttpHandler是否真的在Mono中实现,或者我是否应该使用另一种方法来收集对某个主机和/或虚拟目录的所有请求. 解决方法
HTTP处理程序和模块在Mono中运行良好.
您的问题是您的Web.config文件使用特定于IIS的“集成管道”模式的语法. Apache / mod_mono下不存在此模式.因此,您必须使用旧语法(即“经典流水线”模式的语法)并提供< system.web / httpHandlers>除了现有的< system.webServer / handlers>之外,部分. 请参阅此Web.config示例: <?xml version="1.0"?> <configuration> <system.web> <httpHandlers> <add path="*.rss" verb="*" type="CedricBelin.Web.FeedHandler" /> </httpHandlers> </system.web> <system.webServer> <handlers> <add name="Feed" path="*.rss" verb="*" type="CedricBelin.Web.FeedHandler" /> </handlers> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> </configuration> <验证...>标记非常重要:如果您忘记了它,IIS会抛出错误并抱怨在Integrated Pipeline上下文中使用了未经授权的部分. 下一步是指示Apache服务器将文件的处理转移到mod_mono,如下所示: <VirtualHost *:80> ServerName mono.localhost DocumentRoot "/Library/WebServer/Documents/MonoTest" AddType application/x-asp-net .rss </VirtualHost> AddType application / x-asp-net .rss这一行很重要.请参阅Web.config中的path =“*.rss”与此行中的.rss扩展名之间的关系.如果要处理所有扩展(如示例(path =“*”)),则必须使用ForceType application / x-asp-net替换AddType application / x-asp-net .rss行. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 仅包含所需参数的自定义MembershipUser
- asp.net-mvc – ASP.Net MVC Action方法编译Razor cshtml文
- asp.net – jQuery / ASP MVC – “$.ajax”调用中的parser
- asp.net – 带有WebAPI的Fiddler表现得很不稳定
- 如何为asp.net身份创建安全邮戳值(IUserSecurityStampStore
- 什么用作asp.net会员后端? RavenDB或SqlServer
- asp.net core中使用EF Core自动生成表的Id主键
- asp.net-mvc – 自定义异常过滤器在asp.net MVC中没有被击中
- Asp.net 5 MVC 6,添加facebook电子邮件的权限
- asp.net-core – compilationOptions.emitEntryPoint是什么