customheaders in web.config file

4.5k Views Asked by At

How can i add entities/parameters into my asp.net mvc application. I want to allow cors to send ajax-requests into a database via asp.net webservice. Does anyone have experience fixing this?

<httpProtocol>  
<customHeaders>  
        <add name="Access-Control-Allow-Headers" value="accept, content-type" />  
        <add name="Access-Control-Allow-Origin" value="http://localhost/QvAJAXZfc/opendoc.htm?document=test.qvw&lang=en-US&host=QVS%40servb"/>
        <add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />  
 </customHeaders>  

It shows me an error underlining the lang and the host section of the value, where i want to access.

Warm regards

1

There are 1 best solutions below

6
ManishKumar On

Make sure that you are adding them in correct section. Change the whole url to just localhost and it will work

<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
      <add name="Access-Control-Allow-Headers" value="accept, content-type" />  
      <add name="Access-Control-Allow-Origin" value="http://localhost"/>
      <add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />  
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>