我正在尝试使用ServierStack模板之一创建ServiceStack API(见下文)。我已经完成了我需要的所有必要的更改,并在本地工作正常。但是,当我将其部署到IIS时,我遇到了许多问题。
我得到的第一个问题是,当我尝试查看元数据页面时,我将重定向到login.aspx页面。从网上四处看看,看起来像添加身份验证模式=“无”是问题吗?但是这造成了这个错误:
错误消息401.2。:未授权:由于服务器配置登录失败。
我正在使用IIS 8和My Web Config看起来像这样;
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
..
</appSettings>
<connectionStrings>
..
</connectionStrings>
<system.web>
<authentication mode="None" />
<compilation targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</configuration>
欢迎任何帮助,欢呼。
这是IIS / ASP.NET配置的问题,它在请求到达ServiceStack之前返回未授权的错误。你需要configure IIS to allow anonymous authentication。