简体   繁体   English

如何在ASP.NET 5应用程序中使用OWIN

[英]How to use OWIN in asp.net 5 application

I created my website with the asp.net preview template, I want to try to integrate azure AAD authentication into it. 我使用asp.net预览模板创建了我的网站,我想尝试将Azure AAD身份验证集成到其中。

https://github.com/AzureADSamples/WebApp-OpenIDConnect-DotNet/blob/master/WebApp-OpenIDConnect-DotNet/App_Start/Startup.Auth.cs https://github.com/AzureADSamples/WebApp-OpenIDConnect-DotNet/blob/master/WebApp-OpenIDConnect-DotNet/App_Start/Startup.Auth.cs

I already added the owin packages: 我已经添加了owin软件包:

PM> Install-Package Microsoft.Owin.Host.SystemWeb -Prerelease
Installing NuGet package Microsoft.Owin.Host.SystemWeb.3.0.1.
Successfully installed 'Microsoft.Owin.Host.SystemWeb.3.0.1' to WebApplication2.
PM> Install-Package Owin.Extensions
Installing NuGet package Owin.Extensions.0.8.5.
Successfully installed 'Owin.Extensions.0.8.5' to WebApplication2.

However Visual Studio does not detect yet the Usings 但是,Visual Studio尚未检测到使用情况

using Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;

When I check the references is not there, I know it has changed quite a bit, but how can I make this reference work? 当我检查引用不存在时,我知道它已经发生了很大变化,但是如何使该引用起作用?

The project.json has the dependencies there: project.json在此处具有依赖项:

{
  "webroot": "wwwroot",
  "userSecretsId": "aspnet5-WebApplication2-93831a1b-8997-4395-9587-461f520d1546",
  "version": "1.0.0-*",

  "dependencies": {
    "EntityFramework.SqlServer": "7.0.0-beta4",
    "EntityFramework.Commands": "7.0.0-beta4",
    "Microsoft.AspNet.Mvc": "6.0.0-beta4",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta4",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta4",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta4",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-beta4",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta4",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta4",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta4",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta4",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta4",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta4",
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
    "Microsoft.Framework.ConfigurationModel.UserSecrets": "1.0.0-beta4",
    "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta4",
    "Microsoft.Framework.Logging": "1.0.0-beta4",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta4",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta4",
    "Microsoft.AspNet.Identity.Owin": "2.2.1",
    "Microsoft.Owin.Host.SystemWeb": "3.0.1",
    "Owin.Extensions": "0.8.5"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
    "gen": "Microsoft.Framework.CodeGeneration",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { } //,
    //"dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "postrestore": [ "npm install", "bower install" ],
    "prepare": [ "gulp copy" ]
  }
}

I believe you have to run a restore before you can do anything with this. 我相信您必须先执行还原操作,然后才能执行此操作。 dnu restore should work.... if you're in visual studio, right click on the solution, get to the nuget manager and restore packages dnu restore应该可以工作。...如果您在Visual Studio中,请右键单击该解决方案,转到nuget管理器并恢复软件包

Your sample is not totally useful at vnext. 您的样本在vnext上并不完全有用。

I think you should not use OWIN DLL with asp.net 5. I have read that OWIN was not totally ported to new framework yet. 我认为您不应该将OWIN DLL与asp.net 5一起使用。我已经阅读到OWIN尚未完全移植到新框架上。

Please, see this sample for OpenId at vnext, maybe helpful. 请参阅此样本了对OpenID的vnext,也许有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM