Hi David,
Thanks for your followup. Regarding on your further description, I've done
a test using the HttpModule on my side. It seems the HttpModule can also
work just as in the Global object. I've also added some break point and
debug , the call sequence is as:
1. Application_BeginRequest in HttpModule
2. Application_AuthenticateRequest in httpModule
3. Application_AuthenticateRequest in Global object
And here is the code I used in my tests:
---------------------httpModule----------------------------
public class SecurityHttpModule : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += (new
EventHandler(this.Application_BeginRequest));
application.AuthenticateRequest += new
EventHandler(Application_AuthenticateRequest);
}
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<br>This request is begined" +
DateTime.Now.ToLongTimeString());
}
protected void Application_AuthenticateRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
HttpRequest request = context.Request;
HttpResponse response = context.Response;
context.User = context.User;
if(request.IsAuthenticated)
{
CustomUser user = new CustomUser(context.User.Identity.Name);
context.User = new CustomPrincipal(context.User.Identity, user);
context.Response.Write("<br>This request is authenticated! in
httpmodule" + DateTime.Now.ToLongTimeString());
}
}
public void Dispose() {}
}
-----------------------test page's page load----------------------
private void Page_Load(object sender, System.EventArgs e)
{
CustomPrincipal cp = (CustomPrincipal)HttpContext.Current.User;
Response.Write("<br>" + HttpContext.Current.User.GetType().ToString() );
Response.Write("<br>" + cp.Username );
}
-------------------------------web.config setting--------------------------
<configuration>
<system.web>
<authentication mode="Windows" />
.............
<httpModules>
<add name="SecurityHttpModule"
type="WebApplication1.SecurityHttpModule,
WebApplication1" />
</httpModules>
</system.web>
</configuration>
==================================
Please check out my test codes to see whether it can provide any clues on
this issue. Also, I think you may add some break points in code to trace
the request. And using some "Response.Write" to append some info such as:
context.Response.Write("<br>This request is authenticated! in httpmodule" +
DateTime.Now.ToLongTimeString());
will also be helpful to troubleshoot.
If you have anything unclear, please feel free to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx