Bonjour,
Je coince avec les httpHandlers bien que j'ai saisi le concept (du moins je pense!).
J'ai configuré mon web.config comme suivant :
et ma classe héritée de IHttpHandler :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.5"/> <httpRuntime requestValidationMode="2.0"/> <pages validateRequest="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> <httpHandlers> <add verb="*" path="*.png" type="SymbolHandler"/> </httpHandlers> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> </configuration>
J’appelle le serveur à partir de l'url http://localhost:52598/symbols.axd?s=1-symbole.png mais j'ai une page blanche avec une connexion refusée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class SymbolHandler : IHttpHandler { public SymbolHandler() { } #region IHttpHandler Members public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { context.Response.ContentType = "image/png"; string imageFile = "C:/TMP/" + context.Request.QueryString["s"]; if (File.Exists(imageFile)) { System.Drawing.Image img = System.Drawing.Image.FromFile(imageFile); img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png); img.Dispose(); } } #endregion }
Avez-vous une idée du problème ?
Merci pour votre aide
Partager