C# webapi相關問題記錄

C# Swagger問題記錄:

1、使用nginx代理時無法訪問Swagger

修改文件Web.config;在configuration節點下添加節點(暫未明白該配置項的作用)

<add key="aspnet:UseHostHeaderForRequestUrl" value="true"/>

2、使用nginx代理後出現 Can't read from server. It may not have the appropriate access-control-origin settings
修改文件Web.config;在system.webServer節點下添加節點

<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*"/>
    <add name="Access-Control-Allow-Headers" value="Content-Type"/>
    <add name="Access-Control-Allow-Methods" value="POST, GET, PUT, DELETE, OPTIONS"/>
  </customHeaders>
</httpProtocol>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章