当前位置:编程学习 > C#/ASP.NET >>

ASP.net编程的问题49

    protected void Page_Load(object sender, EventArgs e)
    {
        Bitmap image = new Bitmap(300,50);
        Graphics graphics = Graphics.FromImage(image);
        graphics.Clear(Color.Black);
        Font font = new Font("宋体",16);
        Brush brush = new SolidBrush(Color.White);
        graphics.DrawString("验证图片测试",font,brush,0,0);
        graphics.Dispose();
        Response.Clear();
         Response.ContentType = "image/pjpeg";
        image.Save(Response.OutputStream,ImageFormat.Jpeg);
        image.Dispose();
        Response.End();
    }

 

Response.ContentType = "image/pjpeg";这句代码加了跟不加有什么区别???

效果不就一样???

答案:response.ContentType 不同的ContentType 会影响客户端所看到的效果.默认的ContentType为 text/html 也就是网页格式.

我刚刚百度了一下,大体意思就是和你想的一样,会影响网页显示的效果

但是具体如何影响,效果有什么不一样,可能还需要你自己慢慢尝试

至于加与不加这句话效果可能变化不大,pjpeg是规定了在客户端显示图片所用的格式,contenttype的格式不只这一种,百度上有很多帖子是关于这个格式的详尽阐述,你可以去看看

上一个:ASP.net编程的问题31
下一个:ASP.NET编程的问题43

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,