Reputation: 827
I have a following scenario:
[AuthorizeAttribute]
LayoutView
setting for these 'public' actions are set whether the current user is authenticated (logged in) or not. If they are authenticated, then the whole childView
(displayed by the 'public' actions) is embedded into a master layout page which displays menu for the logged in users etc. The anonymous users have no menu, just the pure childview
page.My problem:
The only solution I can think of is to introduce another controller/actions which call the same BLL logic as the current ones, but have [AuthorizedAttribute]
on them. But this I'd like to avoid, because:
Upvotes: 1
Views: 1245
Reputation: 16038
When you want to keep one Url you have to use the same controller/action for anonymous and authenticated users.
Your problem is, that when a session times out, your authenticated user turns to an anonymous user and generates a new (anonymous) session.
What you can do to distinguish the real anonymous and the sometimes authenticated but now anonymous user is to send a special cookie to all users which had logged in one time in your app.
When such an authenticated usersession times out, the browser will send the cookie to your server and you can redirect him to the login page.
The real anonymous users browser won't send that cookie, so you can just display the page.
Upvotes: 2