简体   繁体   English

我需要配置ASP.net配置文件的帮助

[英]I need help configuring ASP.net Profiles

I'm trying to use ASP.net profiles I've followed some instructions which means I have 我正在尝试使用ASP.net配置文件,我已经按照一些说明进行操作,这意味着我已经

  1. set up a the ASPNETDB (using SQLExpress 2005) 设置一个ASPNETDB(使用SQLExpress 2005)
  2. configured the profile provider (in the web.config) 配置了配置文件提供程序(在web.config中)
  3. defined some properties 定义了一些属性
  4. enabled authentication 启用身份验证

But I can't seem to use code like (ie Intellisense doesn't like it) 但是我似乎无法使用类似的代码(即Intellisense不喜欢它)

Profile.UserCustomContent = "Hi Mom";

It's obvious I've missed something major, but I cannot see, please help me... 很明显,我错过了一些重要的事情,但是我看不到,请帮助我...

Here are some snips from my web.config 这是我的web.config中的一些片段

<connectionStrings>
<add name="SqlServices"
connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalogue=aspnetdb" />
</connectionStrings>

<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>

<profile enabled="true" defaultProvider="SqlServices">
<providers>
<clear/>
<add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices" applicationName="MyInternalApplication" />
</providers>


<properties>
<add name="UserSearchFilterOptions" type="String" />
<add name="UserCustomContent" type="String"/>
</properties>
</profile>
</system.web>

When you add the profile you've called it SqlProvider instead of SqlServices. 添加配置文件后,您将其称为SqlProvider而不是SqlServices。 (the default profile provider name you used above) (您在上面使用的默认配置文件提供程序名称)

This is how I do it.. perhaps there's a different way for your situation. 这就是我的做法。.也许您的情况有另一种方法。

VB - New User.. (True being the value for IsAuthenticated) VB-新用户。(正确是IsAuthenticated的值)

Dim profile As ProfileCommon = ProfileCommon.Create(myUser.UserName, True)
profile.UserCustomContent = "customcontent"

VB - Existing User... VB-现有用户...

Dim profile As ProfileCommon
profile = Profile.GetProfile(myUser.UserName)
profile.UserCustomContent = "customcontent"

C# - New User C#-新用户

ProfileCommon profile = (ProfileCommon) ProfileCommon.Create(myUser.UserName, true);
profile.UserCustomContent = "customcontent";
profile.Save();

C# - Existing User C#-现有用户

ProfileCommon profile;
profile = Profile.GetProfile(myUser.UserName);
profile.UserCustomContent = "customcontent";
profile.Save();

If you are using the Web Application Project, you will need to implement profiles yourself. 如果使用的是Web应用程序项目,则需要自己实施概要文件。 Profiles only work out-of-the-box with the Web Site option. 配置文件只能与“网站”选项一起使用。 The Web Application Project does not have the Profile object automatically added to each page as with the Web Site project, so we cannot get strongly-typed programmatic access to the profile properties defined in our web.config file. 与Web站点项目一样,Web应用程序项目没有将Profile对象自动添加到每个页面,因此我们无法获得对web.config文件中定义的Profile属性的强类型编程访问。

So, if you are using a Web Application Project, this should help: 因此,如果您使用的是Web应用程序项目,则应该会有所帮助:

http://code.msdn.microsoft.com/WebProfileBuilder http://code.msdn.microsoft.com/WebProfileBuilder

However, if you are using the Web Site Project, then this article from Scott Guthrie should lead you in the right direction: 但是,如果您使用的是Web站点项目,那么Scott Guthrie的这篇文章应引导您朝正确的方向发展:

http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

More details on one of my own blog posts on this: 我自己的一篇博客文章的更多详细信息:

http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx http://www.codersbarn.com/post/2008/06/01/ASPNET-Web-Site-versus-Web-Application-Project.aspx

:-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM