I'm trying to debug a httpModule of a sitefinity site which is hosted in IIS 8.5 using Visual Studio 2013. I'm using Sitefinity 8.1 for site development.
Things that I've done till now:
public class UserRoleHttpModule : IHttpModule { public void Init(HttpApplication application) { application.PostAuthenticateRequest += (new EventHandler(this.PostAuthenticateRequest)); } private void PostAuthenticateRequest(Object source, EventArgs e) { UserManager userManager = UserManager.GetManager(); RoleManager roleManager = RoleManager.GetManager(SecurityManager.ApplicationRolesProviderName); roleManager.Provider.SuppressSecurityChecks = true; string[] rolesToAdd = new string[] {"BackendUsers"}; if (userManager.UserExists("rahuln")) { User user = userManager.GetUser("rahuln"); foreach (var roleName in rolesToAdd) { if (roleManager.RoleExists(roleName)) { Role role = roleManager.GetRole(roleName); roleManager.AddUserToRole(user, role); } } } roleManager.SaveChanges(); roleManager.Provider.SuppressSecurityChecks = false; } public void Dispose() { } }
<modules runAllManagedModulesForAllRequests="true"> <remove name="UserRoleHttpModule" /> <add name="UserRoleHttpModule" type="SitefinityWebApp.UserRoleHttpModule"/> </modules>
Now when I run the page from IIS and do the "attach to process" with w3wp.exe in visual studio. I never get a hit on my break points in httpModule. I tried building the solution and the build was successful.
Any help will be greatly appreciated.
Thanks
Are you sure the HttpModule is executing, to verify add the following to PostAuthenticateRequest and it should redirect to microsoft.com if it is.
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Redirect("http://www.microsoft.com");