的SqlProfileProvider - 你能在项目中使用Profile.GetProfile()?能在、项目、SqlProfileProvider、Profile

2023-09-08 09:15:36 作者:介怀

我在尝试使用的SqlProfileProvider在应用程序中似乎无法使用它,我想要的方式。我想能够简单地调用一个配置文件是这样的:

I am attempting to use the SqlProfileProvider in an application and can't seem to use it the way I want to. I would like to be able to simply call up a profile like this:

Profile p = Profile.GetProfile("naspinski");
p.Organization = "new_org";

但我似乎无法找到正确的使用方法中的 GetProfile()的,我仿佛看到散落在网。有没有办法抓住,读取和修改配置文件?

but I can't seem to find the correct way to use the GetProfile() that I seem to see scattered around the net. Is there a way to grab, read and modify profiles?

我用它在MVC 3,并会的不是的实际可登录为特定的用户,这将是从指定的DB拉用户。谢谢你。

I am using it in MVC 3 and will not be actually logging in as the specific user, this will be pulling users from the db that are specified. Thank you.

推荐答案

要获取配置文件:

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

和这里的 MSDN文档。而一个不错的博客帖子有关自定义配置文件。

And here's the MSDN documentation. And a nice blog post about custom profiles.