MVC3单申请表跨子域认证 [英] mvc3 forms authentication across sub-domains in single application

查看:178
本文介绍了MVC3单申请表跨子域认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似这样的问题:
单点登录 - MVC3和Web表单

我有一个自定义路由一个MVC3应用程序,采用子域网址的第一部分,并使用它作为一个变量。因此,例如,test1.mydomain.com给我的控制器可变子域TEST1的值。如果我们test2.mydomain.com类型,那么控制器接收到TEST2。

I have a MVC3 application with custom routing that takes the first part of the sub-domain URL and uses it as a variable. So, for example, test1.mydomain.com gives my controllers the variable subdomain a value of test1. If we type in test2.mydomain.com, then the controllers receive "test2".

问题是与验证(使用内置的窗体身份验证)。如果我登录上,而test1.mydomain.com然后导航到test2.mydomain.com,它不会保留在日志上的子域。当然,如果我向后导航,它表明我登录。

The problem is with authentication (using built-in forms auth). If I log on while on test1.mydomain.com and then navigate to test2.mydomain.com, it doesn't persist the the log on to that subdomain. Of course if I navigate back, it shows that I'm logged in.

我试过下面的两个解决方案,但他们没有工作:
HTTP://www.$c$cproject.com/KB/aspnet/SingleSignon的.aspx
http://stackoverflow.com/questions/608120/forms-authentication-across-sub-domains

I've tried the following two solutions, but they didn't work: http://www.codeproject.com/KB/aspnet/SingleSignon.aspx http://stackoverflow.com/questions/608120/forms-authentication-across-sub-domains

我添加了一个计算机密钥的应用程序,但我不知道这是否是必要的。
注:我仍然在开发框因此域快到了本地主机:2510。因此,例如,我的子域是test1.localhost:2510 test2.localhost:2510。我试着手动设置身份验证cookie域到本地主机,这是行不通的。我告诉你,这种情况下的问题是,我是从localhost的运行。我在根据不同的结合(mysite.com)测试它的过程。如果工作我会更新。不过现在,没有任何人有什么想法?

I've added a Machine Key to the app, though I'm not sure if this was necessary. NOTE: I'm still on the dev box so the domain is coming up localhost:2510. So, for example, my subdomains are test1.localhost:2510 and test2.localhost:2510. I've tried to manually set the auth cookie domain to "localhost" and that doesn't work. I'm telling you this in case the problem is that I'm running from "localhost". I'm in the process of testing it under a different binding (mysite.com). I'll update if that works. For now though, does anyone have any ideas?

推荐答案

我创造了mysite.com域名本地(IIS绑定)和冲浪到我的应用程序那里以后,我发现上的 HTTP://www.$c$cproject.com/KB/aspnet/SingleSignon.aspx 完美的作品。拍我一味精,如果你需要更多的澄清。试图坚持在单个MVC3应用子域之间的认证时本地主机不能使用。

After I created the mysite.com domain name locally (iis binding) and surfing to my application there, I found that the solution given on http://www.codeproject.com/KB/aspnet/SingleSignon.aspx works perfectly. Shoot me a msg if you need any more clarification. Localhost can't be used when trying to persist authentication between sub-domain on a single MVC3 application.

这篇关于MVC3单申请表跨子域认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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