Sunday, August 22, 2010

HTTPModule : ASP.NET 2.0?

Suppose I have site xyz.com. Site has a page called show_user.aspx where I need to access the Session variables.


But this show_user.aspx page will not be called directly Instead , when user type xyz.com/somnath …it will interpret “somnath” as a user name and internally call page show_user.aspx?user=somnath.


I have created a HTTP module URLCheckingModule for URL checking.


This is settings in my web.config file





%26lt;httpModules%26gt;


%26lt;add name="Session" type="System.Web.SessionState.SessionSta...


%26lt;add name="URLChecking" type="UserProfileModule"/%26gt;


%26lt;/httpModules%26gt;


%26lt;pages enableSessionState="true" /%26gt;


%26lt;/system.web%26gt;


%26lt;/configuration%26gt;

HTTPModule : ASP.NET 2.0?
Hey





I am same person, who has asked this question.


I able to resolve the issue.





1. I have added the HTTP module in BeginRequest





that is


app.BeginRequest += new EventHandler(this.OnPreRequest);





2. instead of Server.trasfer I have used ...





context.RewritePath("...





This help me. Session is working properly.
Reply:In order for your module to work, make sure IIS is configured to pass all requests (not just .aspx requests) to the .NET framework.





To access Session from an HTTPModule, you must add the IReadOnlySessionState or the IRequiresSessionState (readonly is better for performance if you don't need to write to the session).


No comments:

Post a Comment