Bjø*_*ørn 7 c# web-config cors signalr
我有两台服务器
我已经把它全部设置好了,它适用于Chrome中的longpolling.(1)使用Firefox并导航到时要求输入用户名和密码https://localhost:44301/signalr/hubs.
(1)使用Windows身份验证.我试图通过执行以下操作来避免身份验证web.config:
<location path="signalr">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
但SignalR不是路径,因为它是自动生成的.我也尝试这样做以暴露集线器,但无济于事:
<location path="~/Hubs">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我找到一种方法从https:// localhost:12321/signalr /*删除身份验证?(这包括所有信号器/协商调用++)
我通过改变问题的前提解决了这个问题。
现在整个服务器都可以匿名访问,但需要 Windows 身份验证的路径已自行指定。
需要保护的控制器的示例如下:
<location path="#####.ashx">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false"/>
<windowsAuthentication enabled="true"/>
</authentication>
<authorization>
<remove users="?" roles="" verbs="" />
<add accessType="Deny" users="?" />
</authorization>
</security>
</system.webServer>
< /location>
Run Code Online (Sandbox Code Playgroud)
以及服务器的一般设置:
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
<windowsAuthentication enabled="true"/>
</authentication>
<authorization>
<add accessType="Allow" users="?" />
</authorization>
<requestFiltering>
<!--Auction searches with 250 results generates slightly longer string than standard setting of 2048-->
<requestLimits maxQueryString="3072" />
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
这可能不是每个人都可行的解决方案,但它对我有用......:)
顺便说一句:在使用此方法时,我还与 IIS Express 进行了斗争,并且能够在 web.config 中设置 Windows 身份验证。这篇文章对我帮助很大 -> IIS Express Windows 身份验证