如何在 asp.net 5 应用程序中使用 OWIN
How to use OWIN in asp.net 5 application
我使用 asp.net 预览模板创建了我的网站,我想尝试将 azure AAD 身份验证集成到其中。
我已经添加了 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.
但是 Visual Studio 还没有检测到 Usings
using Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
当我检查参考文献不存在时,我知道它已经发生了很大变化,但我怎样才能使这个参考文献起作用?
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" ]
}
}
我相信您必须 运行 恢复才能对此进行任何操作。 dnu restore
应该工作....如果你在 visual studio,右键单击解决方案,进入 nuget 管理器并恢复包
您的示例在 vnext 中并不是完全有用。
我认为你不应该将 OWIN DLL 与 asp.net 一起使用 5. 我了解到 OWIN 尚未完全移植到新框架。
请在 vnext 查看此 sample 的 OpenId,可能会有帮助。
我使用 asp.net 预览模板创建了我的网站,我想尝试将 azure AAD 身份验证集成到其中。
我已经添加了 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.
但是 Visual Studio 还没有检测到 Usings
using Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
当我检查参考文献不存在时,我知道它已经发生了很大变化,但我怎样才能使这个参考文献起作用?
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" ]
}
}
我相信您必须 运行 恢复才能对此进行任何操作。 dnu restore
应该工作....如果你在 visual studio,右键单击解决方案,进入 nuget 管理器并恢复包
您的示例在 vnext 中并不是完全有用。
我认为你不应该将 OWIN DLL 与 asp.net 一起使用 5. 我了解到 OWIN 尚未完全移植到新框架。
请在 vnext 查看此 sample 的 OpenId,可能会有帮助。