C# CORS HttpChannel,如何提供正确的标头?
Google Chrome有一个向服务器发送XML-RPC数据的扩展。服务器XML-RPC是一个桌面.NET应用程序 以下是初始化服务器的代码:C# CORS HttpChannel,如何提供正确的标头?,c#,.net,ajax,vb.net,http,C#,.net,Ajax,Vb.net,Http,Google Chrome有一个向服务器发送XML-RPC数据的扩展。服务器XML-RPC是一个桌面.NET应用程序 以下是初始化服务器的代码: Dim properties As IDictionary = New Hashtable properties.Item("name") = "hostChannel" properties.Item("port") = 5678 Dim chnl As New HttpChannel(properties, Nothing, New XmlRp
Dim properties As IDictionary = New Hashtable
properties.Item("name") = "hostChannel"
properties.Item("port") = 5678
Dim chnl As New HttpChannel(properties, Nothing, New XmlRpcServerFormatterSinkProvider)
Try
ChannelServices.RegisterChannel(chnl, False)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(StateNameServer), "statename.rem", WellKnownObjectMode.Singleton)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(CoderServer), "statename.rem", WellKnownObjectMode.Singleton)
Catch ex As Exception
MessageBox.Show("Ошибка")
End Try
向该服务器发送ajax请求时,保护会使CORS无法正常工作,并导致外接程序出错
要使其工作,服务器必须提供正确的头。在浏览器的选项请求中,响应代码200 OK
对于基于Apache的web服务器,此问题已通过以下内容在域根目录中解决
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ blank.php [QSA,L]
如何解决上述HttpChannel
的此问题