asp.net - HttpModule endless redirect -
i'm using httpmodule try , redirect users login page if they're not authenticated, reason it's endlessly redirecting page without landing anywhere.
here's module:
using system; using system.web; using system.web.security; public class authenticationmodule : ihttpmodule { public authenticationmodule() { } public string modulename { { return "authenticationmodule"; } } public void init(httpapplication app) { app.beginrequest += (new eventhandler(application_beginrequest)); } private void application_beginrequest(object source, eventargs e) { httpapplication app = (httpapplication)source; httpcontext context = app.context; httprequest request = context.request; httpresponse response = context.response; if (!request.isauthenticated && !request.rawurl.contains(formsauthentication.loginurl)) { formsauthentication.redirecttologinpage(); } } public void dispose() { } }
i don't recall having ever worked httpmodules before, i'm not sure what's not working.
how can fix this?
request.rawurl url entered browser. check request.rawurl.contains(formsauthentication.loginurl)
case sensitive.
additionally there no checks ressources. each request images, css files etc. redirect login page. need check if authentication required ressource being called.
edit (hit save button early)
additionally on authenticaterequest
Comments
Post a Comment