简体   繁体   English

ASP.NET成员资格未填充新用户

[英]ASP.NET Membership not populating new users

I'm using the ASP.NET Membership provider to handle all membership activities on my current site. 我正在使用ASP.NET成员资格提供程序来处理当前站点上的所有成员资格活动。

I've run into a weird problem. 我遇到了一个奇怪的问题。 As you know, if you are familiar with Asp.Net membership, the data is stored in ProfileCommon. 如您所知,如果您熟悉Asp.Net成员身份,则数据将存储在ProfileCommon中。

So you could do ProfileCommon.UserId to get the userID. 因此,您可以执行ProfileCommon.UserId以获取用户ID。

This all works fine on my production server, my staging server and for old accounts on my local dev server. 所有这些在我的生产服务器,登台服务器以及本地开发服务器上的旧帐户上都可以正常工作。

However, if I create a new user on my local dev server, the Profilecommon object is not being populated and it is throwing errors because pages reference ProfileCommon.UserId for instance and it's null, thus throwing an exception. 但是,如果我在本地开发服务器上创建一个新用户,则不会填充Profilecommon对象,并且会抛出错误,因为页面例如引用ProfileCommon.UserId且该对象为null,从而引发异常。 The user is Authenticated, but ProfileCommon is not being populated. 用户已通过身份验证,但没有填充ProfileCommon。

Does anyone have any ideas/suggestions as to why this might be happening? 是否有人对为什么会这样有任何想法/建议?

Edit: here's my web.config entry. 编辑:这是我的web.config条目。 I'm not sure why we remove AspnetSqlProfileProvider then add it. 我不确定为什么我们删除AspnetSqlProfileProvider然后添加它。 This is a site I took over and I'm not 100% familiar with asp.net membership yet. 这是我接管的网站,但我还不是100%熟悉asp.net成员资格。

  <profile defaultProvider="AspNetSqlProfileProvider">
  <providers>
    <remove name="AspNetSqlProfileProvider"/>
    <add name="AspNetSqlProfileProvider"
         type="System.Web.Profile.SqlProfileProvider" 
         connectionStringName="ConnectionString"/>
</providers>

Actual profile info; 实际个人资料信息;

        <profile defaultProvider="SqlProfileProvider">
        <providers>
            <remove name="AspNetSqlProfileProvider"/>
            <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="FiftyMillionDBConnection"/>
        </providers>
        <properties>
            <add name="FirstName" type="String" serializeAs="String"/>
            <add name="LastName" type="String" serializeAs="String"/>
            <add name="EmailAddress" type="String" serializeAs="String"/>
            <add name="ScreenName" type="String" serializeAs="String"/>
            <add name="BirthDay" type="DateTime" serializeAs="String"/>
            <group name="Address">
                <add name="AddressLine1" type="String" serializeAs="String"/>
                <add name="AddressLine2" type="String" serializeAs="String"/>
                <add name="City" type="String" serializeAs="String"/>
                <add name="State" type="String" serializeAs="String"/>
                <add name="Zip" type="String" serializeAs="String"/>
            </group>
            <group name="PersonalInfo">
                <add name="Gender" type="String" serializeAs="String"/>
                <add name="Height" type="String" serializeAs="String"/>
            </group>
            <group name="OtherInfo">
                <add name="Agent" type="String" serializeAs="String"/>
                <add name="Employee" type="String" serializeAs="String"/>
                <add name="Source" type="String" serializeAs="String"/>
                <add name="EventRegistration" type="String" serializeAs="String"/>
            </group>
            <group name="AuthInfo">
                <add name="GUID" type="String" serializeAs="String"/>
                <add name="RegSource" type="String" serializeAs="String"/>
                <add name="ReceiveMail" type="String" serializeAs="String"/>
            </group>
        </properties>
    </profile>

Thank you! 谢谢!

Is the Profile section in web.config using the same connectionStringName value as the Membership section? web.config中的“个人档案”部分是否使用与“成员资格”部分相同的connectionStringName值? This is the first thing I would check. 这是我要检查的第一件事。

Edit: Can you post your full profile config block? 编辑:您可以发布完整的配置文件配置块吗? You should have something that defines the properties like 您应该有一些定义属性的内容,例如

<profile enabled="true">

    <properties>

        <add name="UserId" type="Int32"/>

        <add name="Gender" type="string"/>

        <add name="Age" type="Int32"/>

    </properties>

</profile>

In addition to the connectionStringName , you may also want to double-check applicationName . 除了connectionStringName ,您可能还需要仔细检查applicationName If they don't match, or you define the application name in one section and not the other, you'll run into issues. 如果它们不匹配,或者您在一个部分而不是另一部分中定义了应用程序名称,则会遇到问题。

   <membership defaultProvider="SqlProvider">
      <providers>
         <add name="SqlProvider"
          type="..."  
          connectionStringName="SomeConnString"
          applicationName="SomeApp"
          ...
          ... />
      </providers>
   </membership>

   <profile defaultProvider="ProfileProvider">
     <providers>
        <clear />
        <add name="ProfileProvider" 
            type="..." 
            applicationName="SomeApp"/>
     </providers>
     <properties>
        ...
     </properties>
  </profile>

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

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