Delete user profile
DeleteProfile.aspx
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Profile" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
Profile.FavoriteAuthor = "Ben Forta";
Profile.Save();
Label1.Text += "Profile data...";
Label1.Text += "<br />favorite Author: " + Profile.FavoriteAuthor;
}
}
protected void Button1_Click(object sender, System.EventArgs e) {
ProfileManager.DeleteProfile(User.Identity.Name);
Profile.Save();
Label2.Text = "Profile deleted successfully!";
Label2.Text += "<br /><br />Profile data[after deleted profile]...";
Label2.Text += "<br />Favorite Author: " + Profile.FavoriteAuthor;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to delete profile in asp.net (ProfileManager.DeleteProfile)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Green">asp.net Profile example: User Profile Delete</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Size="Medium"
Font-Bold="true"
ForeColor="DarkBlue"
>
</asp:Label>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Font-Size="Medium"
Font-Bold="true"
ForeColor="Crimson"
>
</asp:Label>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
Font-Bold="true"
ForeColor="SeaGreen"
Text="Delete Profile"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>
web.config [Modified Parts]
<authentication mode="Windows" />
<profile>
<properties>
<add name="FavoriteAuthor"/>
</properties>
</profile>