Bonjour,
je n'y comprend rien, je n'arrive pas à implémenter une interface HttpModule :
voici mon interface :
Ma classe :
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 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; namespace Portal { interface IHttpModule { // called to attach module to app events void Init(HttpApplication app); // called to clean up void Dispose(); } }
et enfin, mon 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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Security.Principal; namespace Portal { public class SmartCardAuthenticationModule : IHttpModule { private HttpApplication httpApp; void OnAuthentication(object sender, EventArgs a) { HttpApplication application = (HttpApplication)sender; HttpResponse response = application.Context.Response; WindowsIdentity identity = (WindowsIdentity)application.Context.User.Identity; //LogUser(identity.Name); } #region IHttpModule Membres public void Init(HttpApplication app) { this.httpApp = app; httpApp.AuthenticateRequest += new EventHandler(OnAuthentication); } public void Dispose() { throw new NotImplementedException(); } #endregion } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="SmartCardAuthenticationModule" type= "Portal.SmartCardAuthenticationModule" /> </httpModules> </system.web>
Au lancement de la page, voici l'erreur qui apparait dans le navigateur :
Si je supprime l'implementation de mon interface, j'ai exactement le même probleme :Message d'erreur de l'analyseur: Portal.SmartCardAuthenticationModule n'implémente pas IHttpModule. (C:\Users\Moi\Documents\Visual Studio 2008\Projects\SmartCardAuthentication\Portal\web.config line 83)
Erreur source:
Ligne 81 : <httpModules>
Ligne 82 : <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Ligne 83 : <add name="SmartCardAuthenticationModule" type= "Portal.SmartCardAuthenticationModule" />
Ligne 84 : </httpModules>
Ligne 85 : </system.web>
public class SmartCardAuthenticationModule : IHttpModule
De plus, je tiens a signaler que je génère les classe Init() et Dispose() à l'aide visual studio (en version 2008).
Comment prendre en compte correctement cette interface.
aussi pour info : http://msdn.microsoft.com/en-us/library/ff649096.aspx
Merci d'avance
Partager