带有不记名令牌的邮递员 PUT 不起作用

Postman PUT with Bearer Token doesn't work

我尝试使用 Bearer Token 发出 PUT 请求,但没有成功。给出这个问题的唯一方法是 PUT 方法,所有其他方法都工作正常。有人知道为什么吗?

它看起来是 CORS 问题...尝试解决此问题...在您的 webconfig.xml:

<system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
    </modules>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>

然后在您的 StartUp.cs 文件中:

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Owin;
using Owin;
using Microsoft.Owin.Cors;

[assembly: OwinStartup(typeof(DipendentiStatali.API.Startup))]

namespace DipendentiStatali.API
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {




            app.UseCors(CorsOptions.AllowAll); //<--ALLOW CORS FOR ALL OR FOR WHAT HOST YOU WANT
            ConfigureAuth(app);
        }
    }
}

然后尝试将您的请求发送为 JSON 而不是 xx-form-urlencoded