English 中文(简体)
HttpHandler [Image] 无法展示,因为它含有错误。
原标题:HttpHandler [Image] cannot be displayed because it contains errors

奥基一直不停地工作,进行大量搜查。 我无法在从数据库中拿到图像。 如果试图通过人工连接手里,就会获得一个信息,即“由于图像含有错误,不能展示形象”。 此前,我从数据库中看到了一些旧的图像,并首次正确展示这些图像。 但是,现在如果更新图像,我就会发现这一错误。

载荷代码。

if (fileuploadImage.HasFile)
        {
            if (IsValidImage(fileuploadImage))
            {
                int length = fileuploadImage.PostedFile.ContentLength;
                byte[] imgbyte = new byte[length];
                HttpPostedFile img = fileuploadImage.PostedFile;
                img.InputStream.Read(imgbyte, 0, length);

                if (mainImage == null)
                {
                    ProfileImage image = new ProfileImage();
                    image.ImageName = txtImageName.Text;
                    image.ImageData = imgbyte;
                    image.ImageType = img.ContentType;
                    image.MainImage = true;
                    image.PersonID = personID;

                    if (image.CreateImage() <= 0)
                    {
                        SetError("There was an error uploading this image.");
                    }
                }
                else
                {
                    mainImage.ImageName = txtImageName.Text;
                    mainImage.ImageType = img.ContentType;
                    mainImage.ImageData = imgbyte;
                    mainImage.MainImage = true;
                    mainImage.PersonID = personID;

                    if (!mainImage.UpdateImage())
                    {
                        SetError("There was an error uploading this image.");
                    }
                }
            }
            else
            {
                SetError("Not a valid image type.");
            }

这里是我的形象传承者:

public class ImageHandler : IHttpHandler
{
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    public void ProcessRequest(HttpContext context)
    {
        int imageid = Parser.GetInt(context.Request.QueryString["ImID"]);
        ProfileImage image = new ProfileImage(Parser.GetInt(imageid));

        context.Response.ContentType = image.ImageType;
        context.Response.Clear();
        context.Response.BinaryWrite(image.ImageData);
        context.Response.End();
    }

这就是说它“~/ImageHandler.ashx?ImID=”+ Parser.GetString(image.ImageID)

I m利用 s服务器的数据类型图像储存。

Edit:

我也发现,如果要围绕具体情况进行尝试。 答复。

问题回答

我发现我的问题。 我正在核对实际档案的负责人,以确保其有效。 有些情况正在改变数据,使之坏。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签