ASP.NET网络表单的Nancy路由
我一直在尝试在我的webforms项目上实现Nancy.我读过这本指南:
https://github.com/NancyFx/Nancy/wiki/Hosting-nancy-with-asp.net 我已将此添加到我的配置中: <system.webServer> <handlers> <add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="nancy/*" /> </handler> </system.webServer> 我创建了一个带有web.config文件的’/ nancy’文件夹: <?xml version="1.0"?> <configuration> <system.web> <httpHandlers> <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*"/> </httpHandlers> </system.web> </configuration> 我有以下C#代码: public class TestApi : Nancy.NancyModule { public TestApi() : base("/nancy") { Get["/ok"] = parameters => { return "Ok"; }; } } 这在访问’/ nancy / ok’时有效 编辑* 有什么想法我不能做出更具体的路线? 问候Mads 解决方法
根据您的路由判断您希望在url / nancy下运行Nancy,因此任何url都由Nancy处理,而根目录上定义的任何其他内容将继续在ASP.Net Web Forms下运行.
如果是这种情况,问题是您需要将处理程序包装在< location>中.标签: <location path="nancy"> <system.web> <compilation debug="true" targetFramework="4.0" /> <httpHandlers> <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*"/> </httpHandlers> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <validation validateIntegratedModeConfiguration="false"/> <handlers> <add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*"/> </handlers> </system.webServer> </location> 这允许Nancy处理在位置/南希下调用的所有请求(由path =“*”定义). 此信息可以在您将Nancy添加到现有站点下链接到的链接中找到 https://github.com/NancyFx/Nancy/wiki/Hosting-nancy-with-asp.net#adding-nancy-to-an-existing-site ^直接链接到特定标题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc-3 – Azure服务总线 – 双向通信性能挑战
- ASP.NET 5中的手动防伪标记创建和验证
- asp.net – 为什么我收到此错误:System.Security.Security
- asp.net-mvc – 如何在网站上重新创建电子表格或sharepoint
- asp.net-mvc – 如何在ASP.NET MVC中实现分页?
- ASP.NET Core 实现带认证功能的Web代理服务器
- asp.net-mvc – 如何在ASP.NET MVC 3中更新复杂模型
- asp.net-web-api – 如何将OData过滤器转换为LINQ表达式?
- 用Dataset对象读取XML内容来绑定下拉列表框
- asp.net-mvc – “后退”按钮和防伪令牌