c# - Block access to folder with custom login using asp.net webforms -


i have used asp.net membership time, time due requirement cant use asp.net membership. have implement simple login system have validate uses , give them access website section , on other side block access folder logged in users can access contents of these folders.

block access following folders

/english/

/french/

/images/

user should able access contents of these folders if logged in. setting simple session variable when user logs in successfully. let session["userloggedin"] = true.

with asp.net membership can block access folders web.config. not sure how can custom loggin.

any pointer in regarding full.

i'm not sure if work you, have done similar in past (see user isaac's answer bit of guidance): securing web folder out membership roles defined

basically, upon login event assign session variable of "english" or "french" (note i'm not in vs right code might you're looking for):

void protected onlogin() {     if(userisauthenticated)     {         session["english"] = true;     } } 

and in global.asax file should able reference variable if user authenticated:

void application_beginrequest(object sender, eventargs e) {     if(request.physicalpath.contains("english")     {          if(!((bool)session["english"]))              //not "english" user - redirect login or unauthorized page     } } 

again, code taken link gave you, if doesn't work can fish around of projects see i've done in past.

additionally use visual studio 2012 , use asp.net web configuration tool , try work user database working it, i've seen people - bit complicated because have code bit in web.config file, more secure guessing. msdn article might well: http://www.asp.net/web-api/overview/security/external-authentication-services.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -