我在IIS 7.5上运行ServiceStack应用程序,并在/auth/credentials
提供自定义CredentialsAuthProvider。
它可以在Visual Studio中正常工作,但是当我在生产服务器(也是IIS 7.5)上安装它时,它会响应404到/auth/credentials
的所有请求。它在提供REST端点方面没有任何问题,如果我将提供者的超类更改为BasicAuthProvider,则身份验证可以正常工作,但我想使用表单而不是基本身份验证。如何才能正确地为auth端点提供服务?
这就是我的Web.config的样子:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="auth">
<system.web>
<customErrors mode="Off"/>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
</location>
<location path="rest">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</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>
<!-- Required for MONO -->
<system.web>
<httpHandlers>
<add path="rest*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
<add path="auth*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpErrors errorMode="DetailedLocalOnly">
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" prefixLanguageFilePath="" path="https://nearme.solarcity.com" responseMode="Redirect" />
</httpErrors>
<!--<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>-->
<!--uncomment this to stop IIS 7.5 from blocking PUT and DELETE-->
</system.webServer>
</configuration>
答案 0 :(得分:3)
您在配置中做出了错误的假设。
您只能在一条路径上托管ServiceStack,该路径位于根路径*
或自定义路径,通常按惯例/api
或{{ 1}}但可以是您选择的任何名称。 HelloWorld教程shows an example configuration for both supported options。
通过使用[Authenticate]属性装饰Request DTO或Service来强制执行身份验证。如果您愿意,还可以将属性添加到自定义基类,例如/servicestack
这将确保所有子类都需要身份验证。