forms authentication with sql server 2008 database

2019-02-24 20:34发布

Hello I been trying to figure out how to set up ASP.Net forms authentication with sql database I have been trying to figure out how to set up my forms authentication with my sql database. So when I update my admin table it also updates the admin list in the forms authentication.

Any ideas would help thank you!

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-02-24 21:22

Just run the aspnet_regsql.exe tool and the membership database will be created for you. If you run it without any parameters, it will present you with a wizard to guide you through the database creation process.

Here's an example of what you need to add to your Web.Config:

<roleManager enabled="true"/>
<authentication mode="Forms">
    <forms timeout="50000000"/>
</authentication>
<membership defaultProvider="SqlProvider">
    <providers>
    <clear/>
    <add connectionStringName="LocalSqlServer" 
        applicationName="/" 
        enablePasswordRetrieval="false" 
        enablePasswordReset="true" 
        requiresQuestionAndAnswer="false" 
        requiresUniqueEmail="false" 
        passwordFormat="Hashed" 
        minRequiredPasswordLength="6" 
        minRequiredNonalphanumericCharacters="0" 
        name="SqlProvider" 
        type="System.Web.Security.SqlMembershipProvider"/>
    </providers>
</membership>

Also note that you can perform all configuration (except the provider) using the ASP.NET WAT (Web Site Administration Tool) from withing Visual Studio.

Here's a walk-through of the entire process:

Walkthrough: Creating a Web Site with Membership and User Login

查看更多
登录 后发表回答