windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Access-Control-Allow-Origin error when using Owin

Asked By: Anonymous

I’m have a aurelia client and a webserver. When i use localhost and i’m running on the same machine it works fine.

But when i want to access the server from another machine the page loads but the api calls give the following error:
No Access-Control-Allow-Origin header is present on the requested resource.

I’m using owin and to my undestanding i need to enable CORS for owin.

I did the follwing in my startup class:-

I have updated my class with input from Nenad but is still get the same error.
Below i have added the call from the client.

 public void Configuration(IAppBuilder app)

            this.container = new Container();
            // Create the container as usual.
            container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();

            // Register your types, for instance using the scoped lifestyle:
            container.Register<IWebDeps, WebDeps>(Lifestyle.Singleton);

            // This is an extension method from the integration package.
            container.RegisterWebApiControllers(GlobalConfiguration.Configuration, Assembly.GetExecutingAssembly());



            // Configure Web API for self-host. 
            var config = new HttpConfiguration()
                DependencyResolver =
                new SimpleInjectorWebApiDependencyResolver(container)

            var cors = new EnableCorsAttribute("*", "*", "*");

                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            //// Custom Middleare

            //New code:
            app.Run(context =>
                context.Response.ContentType = "text/plain";
                return context.Response.WriteAsync("Hello, world.");

My main program is calling the startUp class:-

  using (Microsoft.Owin.Hosting.WebApp.Start<Startup>("http://localhost:8080"))
                Console.WriteLine("Press [enter] to quit...");

Client code, is the ip from the server.

let baseUrl2 = "";
    getStatus() {
        return this.client.get(baseUrl2)
            .then(response => {
                return this.parseJSONToObject(response.content);

The error in Chrome:

XMLHttpRequest cannot load No
‘Access-Control-Allow-Origin’ header is present on the requested
resource. Origin ‘http://localhost:9000‘ is therefore not allowed
access. The response had HTTP status code 400.

Cors should be enabled now right? But i still get the error when doing a api call. Am i missing any steps? Our is this approah wrong?

Any suggestions are welcome!


Answered By: Anonymous

Turns out that when starting OWIN the adres should be http://*:8080. Instead of local host.

techinplanet staff

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort