如何获得其他用户的在ASP.NET MVC中的个人资料? [英] How to get another user's profile in ASP.NET MVC?

查看:68
本文介绍了如何获得其他用户的在ASP.NET MVC中的个人资料?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要登录时设置cookie与用户的时区。 AccountController.LogOn()好像要做到这一点的最佳场所。但是,我还不能读取用户的个人资料有,因为我猜你只是方法完成时访问配置文件。所以,这code返回一个空字符串:

I want to set a cookie with a user's timezone when they login. AccountController.LogOn() seems like the best place to do this. However, I can't yet read a user's profile there since I guess you only have access to profiles when the method completes. So, this code returns an empty string:

Dim timeZone = HttpContext.Profile("TZ").ToString

一旦用户完全记录上,上述code返回正确的时区。

Once a user has fully logged on, the above code returns the correct TimeZone.

一个解决方法是阅读的用户名试图AccountController.LogOn()登录的个人资料:

One solution is to read the profile for the username trying to log on in AccountController.LogOn():

ProfileCommon profile = Profile.GetProfile(username);  // FAILS

但是,这是行不通的。

However, this doesn't work.

那么,如何阅读给定用户的个人资料,如果他们没有登录?

So, how do I read a given user's profile if they're not logged in?

推荐答案

这并不看上去明显,但一个获得简介:

this doesnt look obvious but is a get Profile:

ProfileBase profile = ProfileBase.Create(HttpContext.Profile.UserName, true);

返回现有的实例。

returns an existing instance.

这篇关于如何获得其他用户的在ASP.NET MVC中的个人资料?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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