对不同的子域不同的应用程序共享asp.net认证 [英] Sharing asp.net authentication on different apps on different sub-domains

查看:87
本文介绍了对不同的子域不同的应用程序共享asp.net认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个应用程序。一个在asp.net web表单 main.test.com 应提供身份验证,用户登录时,我可以使用cookie来在位于我的asp.net MVC应用程序验证 myApp.test.com

I have 2 applications. One on asp.net webforms main.test.com which should provide authentication, user logs in and I can use the cookie to authenticate on my asp.net mvc app located at myApp.test.com.

所有我想要做的是能够访问该Cookie,所以我可以说是用存储在其中的用户id的 FormsAuthentication

All I'd like to do is able to access the cookie so I can get the userId that was stored in it using the FormsAuthentication.

他们使用Microsoft提供正常的认证;

They use normal authentication provided by microsoft;

 <authentication mode="Forms">
     <forms domain="test.com" loginUrl="Default.aspx" protection="All" path="/" requireSSL="false" timeout="45" name=".ASPXAUTH" slidingExpiration="true" defaultUrl="Default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>
 </authentication>

此cookie应该是在test.com权的任何submain访问?

This cookie should be accessible to any submain on test.com right?

推荐答案

请确保您设置机器键中的每个应用程序,使他们每个人都能解密每个人的数据。
http://msdn.microsoft.com/en-us/library/ff649308.aspx

Make sure you set your machine keys in each application so they can each decrypt each others data. http://msdn.microsoft.com/en-us/library/ff649308.aspx

然后确保您已设置您的Cookie名称和路径在每个相同的。完成任务,在任一应用程序生成的权威性机票必须跨越他们两个
http://msdn.microsoft.com/en-us/library/ff647070.aspx

Then make sure you have set your cookie name and path the same in each. Job done, an auth ticket generated in either application should span them both http://msdn.microsoft.com/en-us/library/ff647070.aspx

编辑:忘记了一点:
在你的web配置还设置了httpCookies节点的域属性 test.com

这篇关于对不同的子域不同的应用程序共享asp.net认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆