相关疑难解决方法(0)

如何分配配置文件值?

我不知道我缺少什么,但我在Web.config文件中添加了配置文件属性,但无法访问配置文件.代码中的项目或创建新的配置文件.

asp.net profile asp.net-mvc asp.net-membership

110
推荐指数
4
解决办法
6万
查看次数

Web应用程序项目 - 如何使用ProfileCommon

我正在将我在旧盒子上开发的网站移植到新的开发环境中.我还没有复制所有文件,因为我没有一个很好的文件结构,并且我需要删除一些代码部分.

最初我创建了一个网站(文件 - >新建 - >网站).我想要一个文件结构,如:

用于构建的流行文件夹结构

所以我创建了一个新的空白解决方案,所以sln文件是独立的,然后添加项目(各种DLL项目)和ASP.NET Web应用程序.

这最后一部分似乎给我带来了一些问题,我现在收到以下错误:

"无法找到类型或命名空间名称'ProfileCommon'".

我找到了以下页面:

http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

这似乎有点长,我希望有人可能知道更好的解决方案.

我试图将ProfileCommon与CreateUser向导一起使用,因为我在其中添加了一些额外的信息.

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
    // Create an empty Profile for the newly created user
    ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

    // Populate some Profile properties off of the create user wizard
    p.CurrentLevel = Int32.Parse(((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("clevel")).SelectedValue);

    // Save profile - must be done since we explicitly created it
    p.Save();
}
Run Code Online (Sandbox Code Playgroud)

Web.config文件:

<profile enabled="true">
<properties>
    <add name="CurrentLevel" type="Int32"/>
</properties>
</profile>
Run Code Online (Sandbox Code Playgroud)

如果有另一种方法可以将这些额外信息添加到创建向导中,或者只是更好地为新用户设置额外信息,那么我很满意,非常感激.

感谢您的帮助和建议.

c# asp.net profilecommon

6
推荐指数
2
解决办法
2万
查看次数