C#-ServiceStack凭据身份验证端点提供404
作者:互联网
我正在IIS 7.5上运行ServiceStack应用程序,并在/ auth / credentials中提供了自定义CredentialsAuthProvider.
它可以从Visual Studio正常运行,但是当我将其安装在生产服务器(也就是IIS 7.5)上时,它会响应404对/ auth / credentials的所有请求.服务REST端点没有任何问题,如果我将提供程序的超类更改为BasicAuthProvider,则身份验证有效,但是我想使用表单而不是基本身份验证.如何获得正确服务于身份验证端点的信息?
这是我的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>
解决方法:
您在配置中做出了错误的假设.
您只能在根路径*或自定义路径(通常按照惯例/ api或/ servicestack)中的一个路径上托管ServiceStack,但可以选择任何名称. HelloWorld教程shows an example configuration for both supported options.
通过使用[Authenticate]属性装饰请求DTO或服务来实施身份验证.如果您愿意,还可以将属性添加到自定义基类,例如AuthenticatedServiceBase,它将确保所有子类也需要认证.
标签:iis,servicestack,asp-net,c 来源: https://codeday.me/bug/20191127/2076057.html