Hi,
I have a strange problem.
I created an ASP.NET Handler (AccidentMap.ashx) that gets a bitmap and returns it.
Here is the handler:
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;
}
}
}
}
It retrieves an image via the GetMap method.
If I call this handler in the browser it displays the image:
homepagepreisvergleich.de/img/internet/browser.JPG homepagepreisvergleich.de/img/internet/Property.JPG
So obviously the ashx-handler returns an image.
When I try to display the image within an html-page nothing is displayed.
homepagepreisvergleich.de/img/internet/html.JPG
Here is the html for the page:
<html>
<head>
<title>title</title>
</head>
<body>
<img scr="http://localhost:1849/Modules/Insurance%20Company/AccidentMap.ashx?ID=129" />
</body>
</html>
It is exactly the same url used in both scenarios.
Has somebody got an idea what the reason for this strange behavior is and how to solve it?
Greetings
Alexander