【问题标题】:Add CORS to UseFileServer in OWIN在 OWIN 中将 CORS 添加到 UseFileServer
【发布时间】:2015-03-17 02:37:34
【问题描述】:

我一直在尝试将“Access-Control-Allow-Origin”标头添加到使用自托管 Owin 应用程序提供的文件中

到目前为止,这是我的创业课程

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCors(CorsOptions.AllowAll);

        app.UseFileServer(new FileServerOptions()
        {
            RequestPath = PathString.Empty,
            FileSystem = new PhysicalFileSystem(@"C:\test"),
            EnableDirectoryBrowsing = false,
        });
    }
}

我找到了 UseCors 函数,但它似乎没有帮助。

我也环顾四周并尝试覆盖 UseFileServer 方法,并手动修改标头,但没有这样的运气。

非常感谢任何帮助。

【问题讨论】:

    标签: c# .net cors owin katana


    【解决方案1】:

    我不确定你是否和我做同样的事情,但是将它添加到 App.Config 文件会有所帮助

    <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>
    

    【讨论】:

      猜你喜欢
      • 2015-03-09
      • 2015-06-15
      • 1970-01-01
      • 2016-04-18
      • 2015-02-03
      • 2021-10-14
      • 2019-05-05
      • 2019-08-22
      • 2018-03-23
      相关资源
      最近更新 更多