J'ai un problème étrange..ashx Gestionnaire ASP.NET Image non affichée en html img-element
J'ai créé un gestionnaire ASP.NET (AccidentMap.ashx) qui obtient un bitmap et le renvoie.
Voici le gestionnaire:
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;
}
}
}
}
Il récupère une image via la méthode GetMap.
Si j'appelle ce gestionnaire dans le navigateur, il affiche l'image:
homepagepreisvergleich.de/img/internet/browser.JPG homepagepreisvergleich.de/img/internet/Property.JPG
Alors, évidemment, le gestionnaire ashx-handler renvoie une image.
Lorsque j'essaie d'afficher l'image dans une page HTML, rien ne s'affiche.
homepagepreisvergleich.de/img/internet/html.JPG
Voici le code HTML de la page:
<html>
<head>
<title>title</title>
</head>
<body>
<img scr="http://localhost:1849/Modules/Insurance%20Company/AccidentMap.ashx?ID=129" />
</body>
</html>
Il est exactement la même URL utilisée dans les deux scénarios.
Est-ce que quelqu'un a eu une idée de la raison de ce comportement étrange et comment le résoudre?
Salutations
Alexander
Salut Aric TenEyck, ok, je l'avoue: ce genre whas d'une erreur vraiment stupide! Je me demandais vraiment pourquoi ça ne marchait pas ;-) Quatre yeux voient plus de deux yeux! Merci de votre aide! :-) Salutations Alexander – Alexander