0
ベアラトークンを使用してPUTリクエストを作成しようとしていますが、動作しませんでした。この問題を引き起こす唯一の方法はPUTメソッドですが、他のすべては正常に動作しています。誰でも知っている理由は?ベアラトークンを使用した郵便番号のPUTは動作しません
ベアラトークンを使用してPUTリクエストを作成しようとしていますが、動作しませんでした。この問題を引き起こす唯一の方法はPUTメソッドですが、他のすべては正常に動作しています。誰でも知っている理由は?ベアラトークンを使用した郵便番号のPUTは動作しません
それはCORS問題として見えます...あなたのwebconfig.xmlに。これまでに試してください:あなたのStartUp.csファイル内
<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>
そして:
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);
}
}
}
次に、xx-form-urlencodedの代わりにJSON
というご要望を送信してください。
サーバー? (CORS) –
また正しい形式がform-url-encodedで、代わりにjsonでないことを確認してください。 –
はい、.NET APIには私はform-url-encodedを使用しています。サーバー上のPUTの承認については、次のコマンドを使用してすべてのメソッドを承認します。 context.OwinContext.Response.Headers.Add( "Access-Control-Allow-Origin"、new [] {"*"})); –