This morning, we performed a profile test. The webconfig configuration is as follows:
Code
< Configuration >
< Appsettings />
< Connectionstrings >
< Add name = " Mssqlconnstring " Connectionstring = " Server = WSH-S0712002 \ sql2005; user id = sa; Password = cjchnwscq53b4y; database = replaceshop; min pool size = 4; Max pool size = 4; packet size = 3072 " Providername = " System. Data. sqlclient " > </ Add >
</ Connectionstrings >
< System. Web >
< Compilation debug = " True " />
< Authentication Mode = " Forms " />
< Anonymousidentification Enabled = " True " />
< Profile Enabled = " True " Automaticsaveenabled = " False " Defaultprovider = " Supperstudentprovider " >
< Providers >
< Add name = " Supperstudentprovider " Connectionstringname = " Mssqlconnstring " Type = " System. Web. profile. sqlprofileprovider " Applicationname = " Replaceshop 1.0. " />
</ Providers >
< Properties >
< Add name = " Favoritecolor " Allowanonymous = " True " Defaultvalue = " Red " Provider = " Supperstudentprovider " />
</ Properties >
</ Profile >
</ System. Web >
</ Configuration >
Code
// Anonymous. aspx
<% @ Page Language = " C # " %>
< Script runat = " Server " >
Void Login (Object S, eventargs E)
{
Formsauthentication. setauthcookie ("Bill",False);
Response. Redirect (request. Path );
}
Void Logout (Object S, eventargs E)
{
Formsauthentication. signout ();
Response. Redirect (request. Path );
}
Void Updateprofile (Object S, eventargs E)
{
Profile. favoritecolor=Txtfavoritecolor. text;
}
Void Page_prerender ()
{
Lblusername. Text=Profile. Username;
Lblfavoritecolor. Text=Profile. favoritecolor;
}
</ Script >
< Html >
< Head >
< Title > Anonymous </ Title >
</ Head >
< Body >
< Form ID = " Form1 " Runat = " Server " >
< ASP: button ID = " Button1 "
Text = " Login "
Onclick = " Login "
Runat = " Server " />
< ASP: button ID = " Button2 "
Text = " Logout "
Onclick = " Logout "
Runat = " Server " />
< HR />
< ASP: textbox
ID = " Txtfavoritecolor "
Runat = " Server " />
< ASP: button ID = " Button3 "
Text = " Update Profile "
Onclick = " Updateprofile "
Runat = " Server " />
< HR />
< B > Username: </ B >
< ASP: Label
ID = " Lblusername "
Runat = " Server " />
< BR />
< B > Favorite color: </ B >
< ASP: Label
ID = " Lblfavoritecolor "
Runat = " Server " />
</ Form >
</ Body >
</ Html >
The following error is found:
Stored Procedure 'dbo. aspnet_checkschemaversion' not found'
Solution:
Navigate to the directory c: \ windows \ Microsoft. NET \ framework \ v2.0.50727and execute aspnet_regsql.exe. Be sure to select the database (consistent with the connectionstring in webconfig)