Bonjour,
voici le message d'erreur quand je lance l'appli test:
Voici le fichier qui génère un module Http - projet bibliothèque de classes(chapitre2_cs_module):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Unable to start debugging on the web server. Make sure server is operating correctly. Verify there are no syntx errors in web.config by doing a Debug.Start Without Debugging...
MarqueurModule.cs:
Appli test:
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
29
30
31
32
33
34
35
36
37
38
39 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; namespace chapitre2_cs_module { public class MarqueurModule : IHttpModule { private HttpApplication app; public void Dispose() { } public void Init(HttpApplication context) { app = context; context.BeginRequest += new EventHandler(context_BeginRequest); } void context_BeginRequest(object sender, EventArgs e) { string marqueur = "marque=un+message"; string qs = app.Context.Request.QueryString.ToString(); if (qs != null && qs != "") qs += "&" + marqueur; else qs = marqueur; app.Context.RewritePath(app.Context.Request.FilePath, app.Context.Request.PathInfo, qs); } } }
test_module.espx:
code behind:
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 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_module.aspx.cs" Inherits="test_module" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> </div> </form> </body> </html>
web.config:
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 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class test_module : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Label1.Text = "Requête : " + Request.Path + "<br>QueryString : " + Request.QueryString; } }
J'ai référencé dans le projet test la DLL chapitre2_cs_module.dll
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.web> <compilation debug="true" targetFramework="4.0"/> <httpModules> <add name="MarqueurModule" type="chapitre2_cs_module.MarqueurModule, chapitre2_cs_module"/> </httpModules> </system.web> </configuration>
Si vous avez une solution, merci d'avance.
Partager