2009-10-23 3 views
1

이상한 문제가 있습니다..ashx ASP.NET 처리기 이미지가 html img-element에 표시되지 않습니다.

비트 맵을 가져 와서 반환하는 ASP.NET 처리기 (AccidentMap.ashx)를 만들었습니다. 그것은의 GetMap 방법을 통해 화상을 검색

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 
using System.Drawing; 

namespace BackOffice.Modules.Insurance_Company 
{ 
    /// <summary> 
    /// Summary description for $codebehindclassname$ 
    /// </summary> 
    [WebService(Namespace = "http://tempuri.org/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
    public class AccidentMap : IHttpHandler 
    { 

     public void ProcessRequest(HttpContext context) 
     { 
      try 
      { 
       int id = Convert.ToInt32(context.Request.QueryString["ID"]); 

       System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(context.User.Identity.Name); 


       InsuranceCompany.InsuranceCompany insuranceCompany = new InsuranceCompany.InsuranceCompany(); 

       InsuranceCompany.Accident.Map map = insuranceCompany.GetMap(id, user.UserName, user.GetPassword()); 

       Bitmap bitmap = map.Image; 


       System.IO.MemoryStream stream = new System.IO.MemoryStream(); 
       byte[] bitmapBytes; 

       bitmap.Save(stream, bitmap.RawFormat); 
       bitmapBytes = stream.ToArray(); 

       context.Response.ContentType = "image/jpeg"; 
       context.Response.OutputStream.Write(bitmapBytes, 0, bitmapBytes.Length); 
      } 
      catch 
      { 
      } 
     } 

     public bool IsReusable 
     { 
      get 
      { 
       return false; 
      } 
     } 
    } 
} 

: 여기

핸들러이다.

그래서 분명히

homepagepreisvergleich.de/img/internet/browser.JPG homepagepreisvergleich.de/img/internet/Property.JPG : 나는 브라우저에서이 핸들러를 호출하는 경우

는 이미지를 표시 ashx 핸들러는 이미지를 리턴합니다.

html 페이지 내에 이미지를 표시하려고하면 아무 것도 표시되지 않습니다.

<html> 
<head> 
<title>title</title> 
</head> 
<body> 
<img scr="http://localhost:1849/Modules/Insurance%20Company/AccidentMap.ashx?ID=129" /> 

</body> 
</html> 

그것은 정확히 두 시나리오에서 사용되는 동일한 URL입니다 :

homepagepreisvergleich.de/img/internet/html.JPG 여기

는 페이지의 HTML입니다.

누가이 이상한 행동에 대한 이유가 무엇인지 어떻게 해결할 수 있는지 아이디어를 얻었습니까?

인사말

알렉산더

답변

3

당신은 HTML에서 "IMG의 SCR은"대신 "IMG의 SRC"가?

+0

안녕 Aric TenEyck을, 나는 인정 : 그 정말 바보 같은 실수 whas 종류! 나는 왜 그것이 효과가 없었는지 궁금했다 .- 4 개의 눈은 2 개 이상의 눈을 본다! 도와 주셔서 감사합니다. :-) 인사말 알렉산더 – Alexander

0

당신은 네임 스페이스를 추가하여이 작업을 수행 할 수 있습니다 :

System.Web.SessionState; 

이 좋아 사용 확인

public class Handler : IHttpHandler, IRequiresSessionState 
관련 문제