servicestack - 为什么 ServiceStack 使用此配置返回 404?

标签 servicestack

我有以下配置。

<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 未找到
缓存控制:私有(private)
内容类型:文本/纯文本;字符集=utf-8
服务器:Microsoft-IIS/7.5
X-Powered-By:ServiceStack/3.926 Win32NT/.NET
X-AspNet-版本:4.0.30319
X-Powered-By: ASP.NET
日期:2012 年 11 月 19 日星期一 23:15:46 GMT
内容长度:1528

未找到请求的处理程序:

Request.ApplicationPath:/MyWebApp.Web.UI
Request.CurrentExecutionFilePath:/MyWebApp.Web.UI/services/echo/
Request.FilePath:/MyWebApp.Web.UI/services/echo/
请求.HttpMethod: GET
Request.MapPath('~'): D:\Lib\MyWebApp\2013\MyWebApp\MyWebApp.Web.UI
请求路径:/MyWebApp.Web.UI/services/echo/
请求路径信息:
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.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:本地主机
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:真
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、人力资源、js、obj、属性、样式、_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 重写规则。

最佳答案

额外的system.webServer声明可能会干扰 ServiceStack 从您的 Web.Config 中自动推断托管路径。

您可以尝试手动设置路径以查看是否有帮助,例如在您的 AppHost.Configure() 中:

SetConfig(new HostConfig {
    HandlerFactoryPath = "services",
});

关于servicestack - 为什么 ServiceStack 使用此配置返回 404?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13464247/

相关文章:

c# - 在没有 .ToList() 复制操作的情况下将 List<Concrete> 转换为 List<Inherited Interface>

c# - 如何使用 protobuf 将 ServiceStack 服务与非 ServiceStack 客户端集成?

c# - 如何在 ASP.Net MVC Controller 中正确使用 ServiceStack 认证

c# - ServiceStack流压缩

c# - 在 ServiceStack 中注册自定义凭据身份验证提供程序

c# - ServiceStack DTO 程序集

authentication - 为什么我的 ServiceStack AuthProvider 从不调用 Authenticate(),即使 IsAuthorized() 返回 false?

redis - ServiceStack Redis 客户端的非通用 Store 方法或非通用 GetTypedClient

asp.net-mvc-4 - 如何使用 Redis 缓存自定义列表?

servicestack - 在 ServiceStack 中生成服务的 URL