Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, I think you have to take a look at <a href="https://developer.mozilla.org/en/docs/HTTP/Access_control_CORS" rel="nofollow">Access_control_CORS</a>.<br></p> <p>There is a easy way to solve this problem in MVC.NET. Add Below code to Global.asax</p> <pre><code> protected void Application_BeginRequest(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(Request.Headers["Origin"])) { if (IsOriginInCrossDomainWhiteList(Request.Headers["Origin"])) { Response.AddHeader("Access-Control-Allow-Origin", Request.Headers["Origin"]); } else { Response.End(); } } } internal static bool IsOriginInCrossDomainWhiteList(string origin) { Uri uri; if (Uri.TryCreate(origin, UriKind.Absolute, out uri)) { foreach (var whiteDomain in Properties.Settings.Default.CrossDomainWhiteList) { if (string.Compare(uri.Host, whiteDomain, true) == 0) { return true; } } } return false; } </code></pre> <p>and add some domain to Web.config like :<br></p> <pre><code> &lt;applicationSettings&gt; &lt;YourProject.Properties.Settings&gt; &lt;setting name="CrossDomainWhiteList" serializeAs="Xml"&gt; &lt;value&gt; &lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;string&gt;www.youhost.com&lt;/string&gt; &lt;/ArrayOfString&gt; &lt;/value&gt; &lt;/setting&gt; &lt;/YourProject.Properties.Settings&gt; &lt;/applicationSettings&gt; </code></pre> <p>Then you can use ajax call at the domain added in <code>CrossDomainWhiteList</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload