我想在登录时设置一个用户时区的cookie.AccountController.LogOn()似乎是最好的地方.但是,我还不能在那里读取用户的配置文件,因为我猜你只能在方法完成时访问配置文件.所以,这段代码返回一个空字符串:
Dim timeZone = HttpContext.Profile("TZ").ToString
Run Code Online (Sandbox Code Playgroud)
用户完全登录后,上面的代码将返回正确的TimeZone.
一种解决方案是读取尝试在AccountController.LogOn()中登录的用户名的配置文件:
ProfileCommon profile = Profile.GetProfile(username); // FAILS
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.
那么,如果他们没有登录,我如何阅读给定用户的个人资料?
这看起来并不明显,但是获得一个简介:
ProfileBase profile = ProfileBase.Create(HttpContext.Profile.UserName, true);
Run Code Online (Sandbox Code Playgroud)
返回现有实例.
| 归档时间: |
|
| 查看次数: |
4734 次 |
| 最近记录: |