aps.net2.0配置学习笔记总结1

 

连接数据库

SqlConnection myConnection=new SqlCOnnection()

myConnection.ConnectionString =”Data Source=localhost;”+Initial Catalog=Pubs;Integrated Security=”SSPI”;

<configuration>

<connectionStrings>

<add name=”Pubs” connectionString=”Data Source=localhost;Initial Catalog=Pubs;Integrated Security=”SSPI”

</connectionStrings>

</configuration>

String connectionString=WebConfigurationManager.ConnectionStrings[“Pubs”].ConnectionString;

SqlCommand myCommand=new SqlCommand();

myCommand.Connection=myConnection;

myCommand.CommandText=”Selet * form authors”;

or

SqlCommand myCommand=new SqlCommand(“select *from authors”,myConnection);

配置membership provider

<configuration>

<connectionStrings>

<clear/>

<add name=”LocalSqlServer” providerName=”System.Data.SqlClient”

connectionString=”Data Source=localhost;Integrated Security=SSPI;

AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true”/>

</connectionStrings>

</configuration>

Sqk2000

<configuration>

<connectionStrings>

<clear/>

<add name=”LocalSqlServer” providerName=”System.Data.SqlClient”

connectionString=”Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb”/>

</connectionStrings>

..

<membership defaultProvider=”MyMembershipProvider”>

<providers>

<clear/>

<add

Name=”MyMembershipProvider”

Type=”System.Web.Security.SqlMembershipProvider”

connectionStringName=”LocalSqlServer”

requiresQuestionAndAnswer=”false”

minRequiredPasswordLength=”1”

minRequiredNonalphanumericCharacters=”0”/>

</providers>

</membership>

</configuration>

用代码创建用户:

membership.CreateUser(username,password,email);

自定义注册步骤:

<asp:CreateUserWizard ID=”CreateUserWizard1” runat=”server”..>

<WizardSteps>

<asp:CreateUserWizardStep runat=”server” title=”Create User”>

</asp:CreateUserWizardSetp>

<asp:WizardStep runat=”server” Title=”Subscribe”>

</asp:WizardStep>

<asp:CompleteWizardStep runat=”server”>

</asp:CompleteWizardStep>

</WizardSteps>

</asp:CreateUserWizard>

开启role-based authorization

<configuration>

<system.web>

<roleManager enabled=”true”/>

</system.web>

</configuration>

Profile

<system.web>

<profile defaultProvider=”SqlRrovide”>

<providers>

<clear/>

<add name=”SqlProvider”

Type=”System.Web.Profile.SqlProfileProvider”

connectionStringName=”SqlServices”

applicationName=”TestApplication”/>

</providers>

</profile>


<system.web>

在存入信息至aspnet_Profile 一之前,需要定义明确的需要存入列。将<properties>插入 <profile>标签中如下:

<profile defaultProvider=”SqlProvider”>

<providers>

</providers>

<properties>

<add name=”FirstName” type=”String”/>

</properties>

</profile>

你可能感兴趣的:(.net)