c# - Best practice for redirecting to a page when the user session expires -


i have tried things this question. didn't me. answers seem not working. don't want check whether session null or not , redirect other page in every method. tried redirect in session_end event, not working because not have http context associated it.

so, best practice?

thanks.

best practice not redirect in case this.

let's user on website, , want go http://example.net/theinterestingbit.

now let's imagine session has expired.

was wanted go /theinterestingbit if session alive, otherwise go /someloginpage "successfully"? not.

what wanted go /theinterestingbit , not care "sessions" because that's programmers worry not you. failed isn't success condition, it's error condition.

so don't redirect, instead use httpserverutility.transfer or httpcontext.rewritepath user still goes /theinterestingbit becomes login page or other appropriate means start new session. make sure response uses status-code of 403 it's appropriately noted error page, rather "successful" response.

do in either global.asax or in implementation of ihttpmodule, in response postacquirerequeststate event (because event fires after appropriate session - or lack thereof - has been set). in handler beginrequest if doing there anyway. global.asax easier add in quickly, modules more re-used or set work sections of application , not others.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -