JP Hellemons JP Hellemons - 1 year ago 122
Javascript Question

Cors access-control-allow-origin header not present

I have an owin/katana project. So no IIS.

public void Configuration(IAppBuilder app)
app.Run(context =>
context.Response.ContentType = "application/json";
context.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
// etc.

and client side this jQuery:

dataType: "json",
url: labelPrintLoc,
success: function (msg) {
if (msg === "Done")
else {
alert("Error, check the log on the server!");
error: function(a, b, c) {

enter image description here

XMLHttpRequest cannot load http://xxxx:9000
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://yyy is therfore not allowed access.

I have seen this similar question but there is no
method. I thought that the
gave everyone access?

edit will try option 3 from this url:

edit2 adding the nuget and this line
and remove the line with headers.add gives me a 500 error, because the origin was already set.

Answer Source

This is a webserver Problem.


Excuse my premature answer. If it's self hosted add this to Katana's web.config or system.config:

        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS, PUT, DELETE" />


  <add key="cors:Origins" value="*" />
  <add key="cors:Headers" value="*" />
  <add key="cors:Methods" value="GET, POST, OPTIONS, PUT, DELETE" />

What option works for you, depends on how your server is configured. Sorry, I am not really in to all the microsoft stuff..

This article could be useful to you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download