<legend id='3mZgE'><style id='3mZgE'><dir id='3mZgE'><q id='3mZgE'></q></dir></style></legend>

    1. <small id='3mZgE'></small><noframes id='3mZgE'>

      <tfoot id='3mZgE'></tfoot>

      1. <i id='3mZgE'><tr id='3mZgE'><dt id='3mZgE'><q id='3mZgE'><span id='3mZgE'><b id='3mZgE'><form id='3mZgE'><ins id='3mZgE'></ins><ul id='3mZgE'></ul><sub id='3mZgE'></sub></form><legend id='3mZgE'></legend><bdo id='3mZgE'><pre id='3mZgE'><center id='3mZgE'></center></pre></bdo></b><th id='3mZgE'></th></span></q></dt></tr></i><div id='3mZgE'><tfoot id='3mZgE'></tfoot><dl id='3mZgE'><fieldset id='3mZgE'></fieldset></dl></div>

          <bdo id='3mZgE'></bdo><ul id='3mZgE'></ul>

        即使允许几乎所有内容,ASP.NET 5/Core/vNext CORS 也无法正常工作

        时间:2023-09-14
      2. <small id='DbaZD'></small><noframes id='DbaZD'>

        <legend id='DbaZD'><style id='DbaZD'><dir id='DbaZD'><q id='DbaZD'></q></dir></style></legend>

            <i id='DbaZD'><tr id='DbaZD'><dt id='DbaZD'><q id='DbaZD'><span id='DbaZD'><b id='DbaZD'><form id='DbaZD'><ins id='DbaZD'></ins><ul id='DbaZD'></ul><sub id='DbaZD'></sub></form><legend id='DbaZD'></legend><bdo id='DbaZD'><pre id='DbaZD'><center id='DbaZD'></center></pre></bdo></b><th id='DbaZD'></th></span></q></dt></tr></i><div id='DbaZD'><tfoot id='DbaZD'></tfoot><dl id='DbaZD'><fieldset id='DbaZD'></fieldset></dl></div>

              <tbody id='DbaZD'></tbody>
                <tfoot id='DbaZD'></tfoot>
                  <bdo id='DbaZD'></bdo><ul id='DbaZD'></ul>

                  本文介绍了即使允许几乎所有内容,ASP.NET 5/Core/vNext CORS 也无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 ASP.NET 5 Web API(好吧,无论如何现在都是 MVC)后端,我正在使用

                • 对于实际的 POST 请求(这个没有通过):
                • 解决方案

                  问题实际上在于处理 POST 请求的操作中存在异常,正如 Norgerman 所说,默认异常处理程序清除了 CORS 标头.

                  I have a ASP.NET 5 Web API (Well, MVC now anyway) back-end which I am consuming in with the axios library in my JS app.

                  My CORS config in MVC is the following:

                  public void ConfigureServices(IServiceCollection services)
                  {
                        services.AddMvc();
                        services.AddCors();
                  } 
                  
                  
                  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
                  { 
                        app.UseCors(builder => {
                            builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
                        });
                  }
                  

                  So in other words, I should be allowing every request possible. However, while this fixed preflight requests, a POST requests still gets rejected (I can see it executes on the server, but there's no header in the response so it results in a client side error).

                  Does anyone have any ideas why this wouldn't work ?

                  These are the headers that are returned by the MVC api:

                  • For the OPTIONS preflight (this one passes):
                  • For the actual POST request (this one does NOT pass):

                  解决方案

                  The problem was actually in the fact that there was an exception in the action processing the POST request and as Norgerman mentioned, the default exception handler cleared the CORS headers.

                  这篇关于即使允许几乎所有内容,ASP.NET 5/Core/vNext CORS 也无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用 SignalR 使用跨域连接(CORS - 访问控制允许来源) 下一篇:CORS POST 请求不起作用 - 选项(错误请求) - 不允许来源

                  相关文章

                    <bdo id='iHj82'></bdo><ul id='iHj82'></ul>

                      <tfoot id='iHj82'></tfoot>
                      <i id='iHj82'><tr id='iHj82'><dt id='iHj82'><q id='iHj82'><span id='iHj82'><b id='iHj82'><form id='iHj82'><ins id='iHj82'></ins><ul id='iHj82'></ul><sub id='iHj82'></sub></form><legend id='iHj82'></legend><bdo id='iHj82'><pre id='iHj82'><center id='iHj82'></center></pre></bdo></b><th id='iHj82'></th></span></q></dt></tr></i><div id='iHj82'><tfoot id='iHj82'></tfoot><dl id='iHj82'><fieldset id='iHj82'></fieldset></dl></div>
                    1. <legend id='iHj82'><style id='iHj82'><dir id='iHj82'><q id='iHj82'></q></dir></style></legend>
                    2. <small id='iHj82'></small><noframes id='iHj82'>