c# - 从常规 ASP.NET MVC 在 IIS 上使用 .Net 核心捕获 Asp .Net 身份
问题描述
我在 IIS 上部署了一个 ASP.NET Core Web 应用程序,到目前为止一切正常。我有另一个 ASP.NET MVC 应用程序,它使用 ASP.NET Identity 并将 cookie 注入AspNet.ApplicationCookie
浏览器,然后将我重定向到我的 .Net Core 应用程序。
我需要做的是在我的 .NET Core 应用程序上获取最初插入到 ASP.NET MVC 上的这个用户,并从我以前的应用程序中获得授权的 asp 身份,这两个应用程序具有相同的域,因此我可以看到存储中的 cookie。
问题是:如何配置 .NET Core 应用程序,使其可以通过以前应用程序的 ASP.NET cookie 进行身份验证,ASP.NET MVC 应用程序对我来说也是一个黑盒。
这是我到目前为止所尝试的:
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddIdentityCookies();
app.UseAuthentication();
更新:
这是我添加到我的代码中的内容,但仍然没有得到我以前的身份,我也遇到了一些不熟悉的异常
services.AddAuthentication(option=> {
new CookieAuthenticationOptions { Cookie = {
Domain = ".dev.*****.ru",
Path ="/",
Name= ".AspNet.ApplicationCookie",
}
};
}).AddIdentityCookies(option=>new CookieAuthenticationOptions
{
Cookie = {
Domain = ".dev.*****.ru",
Path ="/",
Name= ".AspNet.ApplicationCookie",
}
});
[2019-04-12 11:25:51.903 +03:00 WRN] Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository 使用内存存储库。密钥不会被持久化到存储中。
[2019-04-12 11:25:51.943 +03:00 WRN] Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager 用户配置文件和 HKLM 注册表均不可用。使用临时密钥存储库。应用程序退出时,受保护的数据将不可用。
[2019-04-12 11:25:51.977 +03:00 WRN] Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager 未配置 XML 加密器。密钥“41c89830-2ef1-48f7-afa5-16680973e6f2”可能以未加密的形式保存到存储中。
解决方案
推荐阅读
- wpf - 如何在更高级别设置datatrigger的绑定数据
- angular - 如何使用 API 获取数据初始化图表?
- javascript - 创建带有背景图像的 Javascript 图库
- javascript - 让这个谷歌翻译小书签在 iframe 中运行?
- excel - 将列值与 Excel 中引用表中的子字符串匹配
- laravel - 如何使用 OctoberCms 发送邮件?
- python - 使用 Tkinter 在类中创建按钮
- javascript - TypeError:无法读取未定义的属性“发送”
- java - 无法删除 cookie (java web)
- java - 有什么方法可以将变量作为参数作为'&'在java中的c ++中所做的那样?