且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

表单身份验证-共享Cookie MVC和Web表单

更新时间:2023-12-01 19:57:52

我目前正为这个完全相同的问题而苦苦挣扎。如果您的示例可用,请发布解决方案。

I am currently struggling with this exact same issue. If you got your example to work, please post the solution.

似乎您已经根据有关MSDN文档完成了所有必需的操作:

It seems that you have done everything that is required based on the relevant MSDN documentation:


除非另有说明,否则名称,保护,路径,validationKey,validation,decryptionKey和解密属性在所有应用程序中必须相同。同样,用于身份验证票证(cookie数据)的加密和验证密钥值以及加密方案和验证方案必须相同。
MSDN源代码

不过,正如评论中提到的@ NightOwl888一样,您需要在两个应用程序中都设置 enableCrossAppRedirects = true

As @NightOwl888 mentioned in the comments though, you need to set enableCrossAppRedirects= true in both applications.

https://docs.microsoft.com/zh-cn/dotnet/api/system.web.security.formsauthentication.enablecrossappredirects?view=netframework-4.7.2

我发现这个较旧的SO问题很有帮助。最终在测试服务器上为我工作,但在生产环境中却没有。必须有其他未记录的相关设置。

I found this older SO question helpful. This ended up working for me on our Test servers, but not in Production. There must be additional undocumented relevant settings.