我不认为经典模式可以处理路由配置。如此处所述 - http://www.asp.net/mvc/tutorials/older-versions/deployment/using-asp-net-mvc-with-different-versions-of-iis-cs - 您确实需要执行其他在经典模式下使用 IIS 7.0 或使用映射到 ASP.NET 框架(aspx、axd、ashx)的文件扩展名时的配置。
我能够使用以下配置获得针对 IIS 7 的经典模式
web.config(部分并使用 preCondition="integratedMode"):
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="servicestack*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack"
verb="*" preCondition="integratedMode" />
</handlers>
</system.webServer>
我在路由中添加了 .aspx 以访问 ASP.NET(我想您也可以使用上面链接中列出的其他解决方案)
Routes
.Add<Hello>("/hello.aspx")
.Add<Hello>("/hello.aspx/{Name}");
我可以提出要求http://localhost/hello.aspx and http://localhost/hello.aspx?name=Test
更新 1
事实证明,<system.webServer>在经典模式下运行时,我可以删除所有 IIS 7 ( ) 元素。我的整个 web.config 如下。您的元素的路径属性是什么?也许您因为路径<httpHandlers>不同而得到 404 ?
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="servicestack*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
<compilation debug="true"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
评论答案:
因此,这在功能上是否等同于您的示例中的 path="api*" ?
不。见这里:http: //msdn.microsoft.com/en-us/library/b6x6shw7%28v=vs.100%29.aspx看看这里
的第 2 节:http ://www.servicestack.net/ ServiceStack.Hello/元素具有自定义路径的<httpHandler>路径属性。
此外,在 Visual Studio 中使用 IIS Express 作为开发服务器。您应该能够模拟标准开发服务器中不会出现的 IIS 7 经典模式问题。http://www.microsoft.com/web/gallery/install.aspx?appid=IISExpress