Again a simple .NET Interview question Writing a HttpModule is a two step process.
Create a class which implements IhttpModule.
public class clsHttpModule : IHttpModule
{
public void Init(HttpApplication
context)
{
this.httpApp = context;
httpApp.Context.Response.Clear();
httpApp.AuthenticateRequest += new
EventHandler(OnAuthentication);
httpApp.AuthorizeRequest += new
EventHandler(OnAuthorization);
....
....
....
}
void OnAuthorization(object
sender, EventArgs a)
{
//Implementation
}
void
OnAuthentication(object sender, EventArgs a)
{
//Implementation
}
}
Make a entry in the web.config file.
<httpModules>
<add name="clsHttpModule"
type="clsHttpModule"/>
</httpModules>
Asked In: Many Interviews |
Alert Moderator