首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >托管在Azure上的Signalr提供了不允许的405方法

托管在Azure上的Signalr提供了不允许的405方法
EN

Stack Overflow用户
提问于 2022-04-12 11:28:18
回答 2查看 215关注 0票数 1

在尝试将我的网站部署到Azure时,Signalr在浏览器上会出现以下错误:

代码语言:javascript
运行
复制
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)  

为此呼吁:

代码语言:javascript
运行
复制
hubs/presence/negotiate?negotiateVersion=1:1

其次是:

代码语言:javascript
运行
复制
Error: Failed to complete negotiation with the server: Error: The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.: Status code '405'  

以下是端点:

代码语言:javascript
运行
复制
app
                .UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                    endpoints.MapHub<PresenceHub>("hubs/presence");
                });

该网站在https上工作,urls的定义如下:

代码语言:javascript
运行
复制
export const environment = {
  production: true,
  apiUrl:'https://vidcallme.azurewebsites.net/api/',
  hubUrl:'https://vidcallme.com/hubs/',
  baseUrl:'/'
};

api起作用,集线器不起作用。

这是Api web.config

代码语言:javascript
运行
复制
<system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\API.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>

客户端是用棱角写的。

这是我的客户端web.config:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Angular Routes" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />   
              </conditions>
              <action type="Rewrite" url="/" />
            </rule>
          </rules>
        </rewrite>
        
       <security>
          <requestFiltering>
            <verbs allowUnlisted="true">
              <add verb="POST" allowed="true" />
            </verbs>
          </requestFiltering>
        </security>
      
      
      </system.webServer>
    </configuration>

相关:SignalR Error 405 (method not allowed) - Negotiate

EN

回答 2

Stack Overflow用户

发布于 2022-04-12 13:32:30

你身边的问题。它显示Allow: GET, HEAD, OPTIONS, TRACE,除了POST。这就是原因。

您可以参考下面的代码。

代码语言:javascript
运行
复制
<security>
  <requestFiltering>
    <verbs allowUnlisted="true">
      <add verb="POST" allowed="true" />
    </verbs>
  </requestFiltering>
</security>
票数 1
EN

Stack Overflow用户

发布于 2022-04-13 08:58:17

这个错误发生在enviorment.prod.ts。

应该是这样的:

代码语言:javascript
运行
复制
export const environment = {
  production: true,
  apiUrl:'https://vidcallme.azurewebsites.net/api/',
  hubUrl:'https://vidcallme.azurewebsites.net/hubs/',
  baseUrl:'/'
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71841824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档