在aspx上显示图像的性能问题 [英] performance problem showing image on aspx

查看:70
本文介绍了在aspx上显示图像的性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要在那个图像框中有一个输入控制的aspx页面。如果用户上传最多4张小于1 mb的图像,则每次用户登录其帐户时都可以显示其他详细信息。如果我加载四个图像浏览器获取环聊,它会自动崩溃并关闭。请给出一些建议或解决方案,以便从浏览器环聊中恢复这种性能问题。什么是最好的方法来做这个要求。



这里是我的代码,用于显示图像控制中的图像网址:



Hi,

i have requirement in that one aspx page with many input control in that image box also. if user upload maximum of 4 images with less than 1 mb, that can be shown every time user login into his account with other details also. if i load that four images browser get hangout,it crashed and closed automatically. pls give some suggestion or solution to recover this performance kind of issues from browser hangout. what will be best ways to do this requirement.

here is my code for showing that images in image control url :

string strQuery = "select Name, Data from tblFiles where userid=@id";
        SqlCommand cmd = new SqlCommand(strQuery);
        cmd.Parameters.Add("@id", SqlDbType.Int).Value
        = Convert.ToInt32 (5248);
        DataTable dt = GetData(cmd);
if (dt != null)
        {
	if(dt.Rows[0]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[0]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image1.ImageUrl = "data:image/png;base64," + base64String;	
}
if(dt.Rows[1]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[2]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image2.ImageUrl = "data:image/png;base64," + base64String;	
}
if(dt.Rows[2]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[2]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image3.ImageUrl = "data:image/png;base64," + base64String;	
}
if(dt.Rows[3]["Data"] !=DBNull.Value)
	{
	byte[] bytes = (byte[])dt.Rows[3]["Data"];
        string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
        Image4.ImageUrl = "data:image/png;base64," + base64String;	
}
}

推荐答案





为什么不将它保存在授权目录中并使用它的URL而不是将它们来回转换为base64?建议在短图像上使用Base64,而不是更大的图像。



希望这有帮助!
Hey

Why don't you save it on an authorized directory and use it's URL instead of having them converted to base64 back and forth? Base64 is recommended on short images, not the bigger ones.

Hope this helps!


这篇关于在aspx上显示图像的性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆