Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Anyone familiar with Microsoft.Owin.Cors.CorsMiddleware?

Anyone familiar with Microsoft.Owin.Cors.CorsMiddleware?

Scheduled Pinned Locked Moved C#
questioncomhelptutorialworkspace
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alaric_
    wrote on last edited by
    #1

    So, I've got an open question on so We're experiencing cors issues with signalR resources and I can't imagine that I'm the only one that has had to solve this problem. The "default", documented configuration settings for enabling cors with signalR are

    public void Configuration(IAppBuilder app)
    {
    app.UseCors(CorsOptions.AllowAll);
    app.MapSignalR();
    }

    but CorsOptions.AllowAll configures wildcard Access-Control-Allow-Origin and you cannot specify a wildcard value AND use withCredentials. So I'm investigating what it would take to create a custom Microsoft.Owin.Cors.CorsMiddleware or create a different CorsOptions setting. Does anyone have an example that replaces

    app.UseCors(CorsOptions.AllowAll)

    with

    app.UseCors("CorsOptions with a CorsPolicy that doesn't specify wildcard origins")

    "I need build Skynet. Plz send code"

    A 1 Reply Last reply
    0
    • A Alaric_

      So, I've got an open question on so We're experiencing cors issues with signalR resources and I can't imagine that I'm the only one that has had to solve this problem. The "default", documented configuration settings for enabling cors with signalR are

      public void Configuration(IAppBuilder app)
      {
      app.UseCors(CorsOptions.AllowAll);
      app.MapSignalR();
      }

      but CorsOptions.AllowAll configures wildcard Access-Control-Allow-Origin and you cannot specify a wildcard value AND use withCredentials. So I'm investigating what it would take to create a custom Microsoft.Owin.Cors.CorsMiddleware or create a different CorsOptions setting. Does anyone have an example that replaces

      app.UseCors(CorsOptions.AllowAll)

      with

      app.UseCors("CorsOptions with a CorsPolicy that doesn't specify wildcard origins")

      "I need build Skynet. Plz send code"

      A Offline
      A Offline
      Alaric_
      wrote on last edited by
      #2

      so...when the heck did nested object initializers become good form??? (Note that this seems to be the only way to interact with the Origins collection. Once the CorsOptions object is constructed, there is no direct access to the properties on the PolicyResolver)

      CorsOptions cors = new CorsOptions
      {
      PolicyProvider = new CorsPolicyProvider
      {
      PolicyResolver = context =>
      {
      var policy = new CorsPolicy
      {
      AllowAnyOrigin = false,
      AllowAnyHeader = true,
      AllowAnyMethod = true,
      SupportsCredentials = true
      };

                          policy.Origins.Add("http://localhost");
                      }
                  }
              };
              app.UseCors(cors);
      

      "I need build Skynet. Plz send code"

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups