具有承载令牌的邮差PUT不起作用

时间:2017-01-07 14:42:06

标签: ionic-framework postman put bearer-token

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

enter image description here

1 个答案:

答案 0 :(得分:0)

它看起来像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