的SqlProfileProvider - 你能在项目中使用Profile.GetProfile()? [英] SqlProfileProvider - can you use Profile.GetProfile() in a project?

查看:217
本文介绍了的SqlProfileProvider - 你能在项目中使用Profile.GetProfile()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用的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文档。而一个<一个href="http://weblogs.asp.net/jgalloway/archive/2008/01/19/writing-a-custom-asp-net-profile-class.aspx"相对=nofollow>不错的博客帖子有关自定义配置文件。

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

这篇关于的SqlProfileProvider - 你能在项目中使用Profile.GetProfile()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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