0
我在動態創建圖像,需要向用戶顯示這些圖像。 因爲我已經創建了一個ashx文件,但問題是這個ashx文件永遠不會被調用不知道爲什麼路徑問題或需要添加web.config中的任何標籤.. 而調試它不會去..可能是它沒有發現 請指教。在MVC中創建圖像的Ashx文件ASP.net
編輯:在上下文才知道那個會話無效任何理由:當我直接打ashx的URL它去和表現出一些結果
EDIT 1?
或MVC asp.net不需要ashx處理程序請指教。
/// <summary>
/// Summary description for $codebehindclassname$
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GetImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Log.Info(" In theGetImage");
context.Response.Clear();
byte[] imageByteArray = System.Convert.FromBase64String(context.Session["FrontJpegBase64"].ToString().Replace(' ', '+'));
// System.IO.MemoryStream imageMemoryStream = new System.IO.MemoryStream(imageByteArray);
try
{
using (System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(imageByteArray)))
{
img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
catch (System.Exception ex)
{
}
finally
{
// img.Close();
context.Response.Flush();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
謝謝你們工作 – batwadi 2009-11-20 16:55:25