ASP.NET配置文件属性 - 使用C#MVC

时间:2013-01-15 21:58:34

标签: c#

我使用的是使用.NET 4.0的C#MVC

我正在尝试实现

中看到的ASP.NET配置文件属性

http://msdn.microsoft.com/en-us/library/2y3fs9xs.aspx

首先,我在web.config文件中添加了以下内容。请注意,我正在尝试存储给定用户的位置:

    <profile>
     <properties>
      <add name="Location" />
     </properties>
     <providers>
      <clear />
      <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
     </providers>
    </profile>

在我的代码中,我使用了以下内容:

发布后,我在控制器中使用了以下内容:

      Profile.Location = model.Location; 

我收到错误,无法解析'个人资料'。有没有人使用可提供任何帮助的Profile Property?请注意,我甚至无法找到文章中提到的类。

由于

1 个答案:

答案 0 :(得分:0)

个人资料必须属于用户/会员,因此您需要在向其添加任何个人资料属性之前加载或创建新用户。

See this SO post on a similar question