你能告诉我下面的代码有什么问题吗,我得到了Value of type '2-dimensional array of String' cannot be converted to 'System.Collections.Generic.Dictionary(Of String, String)'
VB.net 代码:
MyBase.SetConfig(New EndpointHostConfig() With {
.GlobalResponseHeaders = {
{"Access-Control-Allow-Origin", "*"},
{"Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"},
{"Access-Control-Allow-Headers", "Content-Type"}
}
})
这是我用作起点的 C# 代码:
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders = {
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
{ "Access-Control-Allow-Headers", "Content-Type" },
},
});
非常感谢任何建议
以下工作正常:
Dim CorsHeaders As New Dictionary(Of String, String)
CorsHeaders.Add("Access-Control-Allow-Origin", "*")
CorsHeaders.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
CorsHeaders.Add("Access-Control-Allow-Headers", "Content-Type")
MyBase.SetConfig(New EndpointHostConfig() With {
.GlobalResponseHeaders = CorsHeaders
})