ASP.NET MVC - 跨子域认证/会员 [英] ASP.NET MVC - cross sub domain authentication/membership

查看:138
本文介绍了ASP.NET MVC - 跨子域认证/会员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命中一个路障,而实施<一个href=\"http://stackoverflow.com/questions/1170008/building-a-language-switcher-2-languages-only-asp-net-mvc\">sub基于域的语言切换器(en.domain.com负载英语,jp.domain.com加载日语)。

Hit a roadblock while implementing a sub domain based language switcher (en.domain.com loads English, jp.domain.com loads Japanese).

我如何得到一个会员制在多个子域名(ASP.NET MVC C#)?工作

看到一些有关添加域=domain.com&LT;形式&gt;在网页项。配置。这样做,但当地的Visual Studio开发Web服务器上进行测试时的工作?

Saw something about adding domain="domain.com" to <forms > entry in web.config. Did that, but does that work when testing on local visual studio development web server?

推荐答案

尝试创建自己的cookie。

Try creating the cookie yourself.

的AccountController 的你会发现这样的:

FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);

这是创建并添加到Cookie集合。它不允许域的修饰(但允许路径的修改,奇怪的)。相反,创建一个cookie不会增加收集,修改必要属性,然后添加到集合:

that "creates and adds to the cookie collection". It doesn't allow modification of the domain (but does allow modification of the path, oddly). Instead create a cookie without adding to the collection, modify the necessary properties, then add to the collection:

var a = FormsAuthentication.GetAuthCookie(userName, createPersistentCookie);
//if you're debugging right here, a.Domain should be en.example.com; change it
a.Domain = "example.com";
HttpContext.Current.Response.Cookies.Add(a);

詹姆斯

这篇关于ASP.NET MVC - 跨子域认证/会员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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