Get profile by user name
GetProfile.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
Profile.FavoriteProduct = "ColdFusion";
Profile.Save();
}
}
protected void Button1_Click(object sender, System.EventArgs e) {
ProfileCommon userProfile = Profile.GetProfile(TextBox1.Text.ToString());
Label1.Text = "<br />User's Favorite Product: " + userProfile.FavoriteProduct;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to get profile in asp.net (Profile.GetProfile)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">asp.net Profile example: Profile.GetProfile()</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Medium"
Font-Bold="true"
ForeColor="SeaGreen"
>
</asp:Label>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Font-Bold="true"
ForeColor="HotPink"
Text="User Name"
>
</asp:Label>
<asp:TextBox
ID="TextBox1"
runat="server"
BackColor="HotPink"
ForeColor="AliceBlue"
>
</asp:TextBox>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Font-Bold="true"
ForeColor="DodgerBlue"
Text="Get Profile"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>
web.config [Modified Parts]
<authentication mode="Windows" />
<profile>
<properties>
<add name="FavoriteProduct"/>
</properties>
</profile>


