我正在尝试使用asp.net Profile功能来存储用户信息.我在配置文件属性中有一个图像.
我正在使用Visual Studio中asp.net提供的默认配置文件提供程序.
以下是web.config中属性的定义
<properties>
<add name="FirstName"/>
<add name="MiddleName"/>
<add name="LastName"/>
<add name="ProfileImage" type="System.Byte[]" defaultValue='null'/>
<add name="MobileNumber"/>
<add name="TelephoneNumber"/>
</properties>
Run Code Online (Sandbox Code Playgroud)
这是代码:
protected void Button1_Click(object sender, EventArgs e)
{
var profile = HttpContext.Current.Profile;
profile.SetPropertyValue("FirstName", TextBox1.Text);
profile.SetPropertyValue("LastName",TextBox3.Text);
profile.SetPropertyValue("MiddleName", TextBox2.Text);
profile.SetPropertyValue("MobileNumber", TextBox4.Text);
profile.SetPropertyValue("TelephoneNumber", TextBox5.Text);
if (IsPostBack)
{
Boolean fileok = false;
String path = Server.MapPath("~/UploadedImages/");
path = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(path);
if (FileUpload1.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedextensions = { ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < allowedextensions.Length; …Run Code Online (Sandbox Code Playgroud)