我有以下配置。
<location path="services">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
如果我添加另一个<system.webServer />
部分,而不是location
个元素,ServiceStack会为所有请求返回404。删除它,一切都恢复正常。
以下是一个示例回复:
HTTP/1.1 404 Not Found Cache-Control: private Content-Type: text/plain; charset=utf-8 Server: Microsoft-IIS/7.5 X-Powered-By: ServiceStack/3.926 Win32NT/.NET X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Mon, 19 Nov 2012 23:15:46 GMT Content-Length: 1528 Handler for Request not found: Request.ApplicationPath: /MyWebApp.Web.UI Request.CurrentExecutionFilePath: /MyWebApp.Web.UI/services/echo/ Request.FilePath: /MyWebApp.Web.UI/services/echo/ Request.HttpMethod: GET Request.MapPath('~'): D:\Lib\MyWebApp\2013\MyWebApp\MyWebApp.Web.UI Request.Path: /MyWebApp.Web.UI/services/echo/ Request.PathInfo: Request.ResolvedPathInfo: /services/echo Request.PhysicalPath: D:\Lib\MyWebApp\2013\MyWebApp\MyWebApp.Web.UI\services\echo\ Request.PhysicalApplicationPath: D:\Lib\MyWebApp\2013\MyWebApp\MyWebApp.Web.UI\ Request.QueryString: Request.RawUrl: /MyWebApp.Web.UI/services/echo/ Request.Url.AbsoluteUri: http://localhost/MyWebApp.Web.UI/services/echo/ Request.Url.AbsolutePath: /MyWebApp.Web.UI/services/echo/ Request.Url.Fragment: Request.Url.Host: localhost Request.Url.LocalPath: /MyWebApp.Web.UI/services/echo/ Request.Url.Port: 80 Request.Url.Query: Request.Url.Scheme: http Request.Url.Segments: System.String[] App.IsIntegratedPipeline: True App.WebHostPhysicalPath: D:\Lib\MyWebApp\2013\MyWebApp\MyWebApp.Web.UI App.WebHostRootFileNames: [global.asax,global.asax.cs,header.html,list.html,login.html,MyWebApp.web.ui.csproj,MyWebApp.web.ui.csproj.user,packages.config,web.config,bin,humanresources,js,obj,properties,styles,_sgbak] App.DefaultHandler: DefaultHttpHandler App.DebugLastHandlerArgs: GET|/MyWebApp.Web.UI/services/echo/|D:\Lib\MyWebApp\2013\MyWebApp\MyWebApp.Web.UI\services\echo\
是否有可能有另一个system.webServer
部分?我想在那里添加IIS url重写规则。
答案 0 :(得分:4)
额外的system.webServer
声明可能会干扰ServiceStack从Web.Config自动引用托管路径。
您可以尝试手动设置路径以查看是否有帮助,例如在AppHost.Configure()中:
SetConfig(new HostConfig {
HandlerFactoryPath = "services",
});