小编use*_*625的帖子

字符串或二进制数据将被截断.该语句已终止.上传个人资料时

我正在尝试使用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)

c# asp.net profile image visual-studio-2013

4
推荐指数
1
解决办法
6万
查看次数

标签 统计

asp.net ×1

c# ×1

image ×1

profile ×1

visual-studio-2013 ×1