No OWIN authentication manager is associated with the request

前端 未结 7 1539
故里飘歌
故里飘歌 2020-12-08 01:37

After trying to enable owin & AspNet Identity to my Web Api project (in VS 2013 + .Net 4.5.1) I get the following error in each valid or unvalid(request to none exist co

相关标签:
7条回答
  • 2020-12-08 02:04

    My case, it failed since this settings in web.config. Hope this helps someone to avoid it.

    <appSettings>
        <add key="owin:AutomaticAppStartup" value="false" />
    </appSettings>
    
    0 讨论(0)
  • 2020-12-08 02:07

    I originally created the project with authentication, but then decided to disable it. I had to remove this in the WebApiConfig.cs file. Make sure you have this if you intend to enable authentication.

            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
    
    0 讨论(0)
  • 2020-12-08 02:12

    if you don't actually need OWIN you can simply uninstall it.

    one way to do it is in Nuget Manager uninstall every OWIN library, the order will be dictated by their dependencies.

    after this is done you don't need any OWIN related code or config. this worked out best for me since I am using windows auth.

    0 讨论(0)
  • 2020-12-08 02:19

    For .Net framework adding the runAllManagedModulesForAllRequests attribute to the modules in web.config . This way I kept the authentication exist.

    <modules runAllManagedModulesForAllRequests="true">
    
    0 讨论(0)
  • 2020-12-08 02:21

    Changing the owin:AutomaticAppStartup key to true in Web.config fixed this for me, i.e. change it from:

    <appSettings>
        <add key="owin:AutomaticAppStartup" value="false" />
    </appSettings>
    

    to this:

    <appSettings>
        <add key="owin:AutomaticAppStartup" value="true" />
    </appSettings>
    
    0 讨论(0)
  • 2020-12-08 02:22

    I had the same problem. The package was not appearing in the NuGet Package manager. I added reference in packages.config:

     <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />
    

    And reference in the project file (xxx.csproj):

     <Reference Include="Microsoft.Owin.Host.SystemWeb">
      <HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.2.1.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
    </Reference>
    
    0 讨论(0)
提交回复
热议问题