---
# System prepended metadata

title: 跨域
tags: [c#, 火箭]

---

# 跨域
###### tags: `火箭` `c#`
# Web.config
```csharp=
<system.webServer>
 <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Methods" value="*" />
        <add name="Access-Control-Allow-Headers" value="Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers,Authorization" />
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Credentials" value="true" />
      </customHeaders>
 </httpProtocol>
</system.webServer>
```

# gobal.asmx
```csharp=
 protected void Application_BeginRequest()
        {
            if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS")
            {
                Response.End();
            }
        }
```