Web Config Tool - Specified cast is not valid

Discussion in 'ASP .Net Security' started by df, Aug 1, 2006.

  1. df

    df Guest

    I'm seeing a strange problem in the Web App config tool: After
    creating a role and a user, going back to the Security tab home page, I
    get a "Specified cast is not valid" error.

    I've set up my web application to use SQL Server to store the
    Membership database using aspnet_regsql.exe and have successfully
    opened the Web Config Tool.

    Then, I create a role, and go look in the SQL Server aspnet_roles
    table, and there is the role. All good.

    Now, when I go to the Web Config tool, and create a user, it saves
    correctly, and can be seen in the aspnet_users table in the DB, but
    when I go back to the Security home page of the Web Config Tool, I get
    the above error and can no longer use the tool to manage the users and
    roles.

    If I delete the Applcation, Membership, User and Role rows from the DB
    and go back to the Web App Config tool, everythign is fine.

    When I try to create the role and user again, the same thing happens.

    The whole error message in the Web Config Tool is:
    "
    There is a problem with your selected data store. This can be caused
    by an invalid server name or credentials, or by insufficient
    permission. It can also be caused by the role manager feature not being
    enabled. Click the button below to be redirected to a page where you
    can choose a new data store.

    The following message may help in diagnosing the problem: Specified
    cast is not valid.
    "

    Also, it seems that the same thing happens if I create a User, without
    creating a Role first. I have tried running aspnet_regsql.exe again,
    but it didn't help.


    Ideas?

    Dan

    Web.Config looks like this:

    <system.web>
    <authentication mode="Forms" />
    <membership>
    <providers>
    <remove name="AspNetSqlMembershipProvider"/>
    <add name="AspNetSqlMembershipProvider"
    connectionStringName="MyConnection" applicationName="/WebApp"
    type="System.Web.Security.SqlMembershipProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    enablePasswordRetrieval="false" enablePasswordReset="true"
    requiresQuestionAndAnswer="true" requiresUniqueEmail="false"
    passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
    minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1"
    passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
    </providers>
    </membership>
    <profile enabled="true">
    <providers>
    <remove name="AspNetSqlProfileProvider"/>
    <add name="AspNetSqlProfileProvider"
    connectionStringName="MyConnection" applicationName="/WebApp"
    type="System.Web.Profile.SqlProfileProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
    </profile>
    <roleManager enabled="true">
    <providers>
    <remove name="AspNetSqlRoleProvider"/>
    <add name="AspNetSqlRoleProvider" connectionStringName="MyConnection"
    applicationName="/WebApp" type="System.Web.Security.SqlRoleProvider,
    System.Web, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a" />
    <remove name="AspNetWindowsTokenRoleProvider"/>
    <add name="AspNetWindowsTokenRoleProvider" applicationName="/WebApp"
    type="System.Web.Security.WindowsTokenRoleProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
    </roleManager>
    ....
     
    df, Aug 1, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    1
    Views:
    3,612
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  2. Floela
    Replies:
    3
    Views:
    574
    Jon Skeet
    Jul 10, 2003
  3. Arjen
    Replies:
    1
    Views:
    7,772
    Carl Prothman [MVP]
    Aug 6, 2003
  4. Alan Silver
    Replies:
    5
    Views:
    2,590
    Kevin Spencer
    Feb 15, 2005
  5. df
    Replies:
    0
    Views:
    505
Loading...

Share This Page