c# - 在 cors 主机中设置时是否需要在 C# 中定义协议
问题描述
我有一个关于 c# 的小问题。我是新手,实际上不是开发人员,但我需要知道一件事。在一个appsetting.json
文件中,我有以下代码:
},
"Cors": {
"AllowedOrigins": ["localhost:4000"]
}
所以我的问题是我需要在这个地方定义协议并像这样写吗
},
"Cors": {
"AllowedOrigins": ["http://localhost:4000"]
}
当我尝试发送一些请求时,如果没有 http,服务器会以 204 No content code 响应。
解决方案
是的,您需要在来源中包含该方案。
这两个 URL 具有相同的来源:
https://example.com/foo.html
https://example.com/bar.html
以下 URL 的来源与前两个 URL 不同:
https://example.net
– 不同的域https://www.example.com/foo.html
– 不同的子域http://example.com/foo.html
– 不同的方案https://example.com:9000/foo.html
– 不同的端口
推荐阅读
- selenium - 使用 nunit + jenkins 并行测试桌面应用程序
- wordpress-theming - WordPress主题开发
- javascript - AWS Cognito 返回未定义错误 async/await
- javascript - setState "TypeError: Cannot read property 'value' of undefined" 当使用不同的输入和一个 onChange 处理程序时
- dart - 如何使用一个动态高度行创建 3 行 Flutter 布局
- amazon-web-services - 第一次尝试后物联网板与 MQTT 协议断开连接
- javascript - 从持久存储重新水化后,Vuex getter 不会更新
- bash - 使用 sed 更改 bash 脚本中可能的关键字之间的文本
- c# - 如何将 Zip 文件创建进度异步报告到状态栏?
- jmeter - 告诉http请求不要让jmeter失败