ASP.NET MVC membership doesn't seem to work if user know direct url -
I'm expanding the default asp.net mvc example. I am using asp.net subscription provider Comes with it. .
The issue is that if I reach directly without entering one of my URLs then the entire page shows the full page with the link "Logon" at the top.
I want to redirect this clear to the login page, if any specific action enters the URL and is not logged in.
Do I "login in" for every action of every controller?
You need to decorate your administrator tasks "[Authorize"] and the correct login in web config Install the page, so whenever a decoration is punished, it checks that the user is logged on and does not redirect to the appropriate login page.
Edit: Here's an example on how to configure:
in web.config ... add:
& lt ; Authentication mode = "form" & gt; & Lt; Forms loginUrl = "~ / account / logon. Espx" timeout = "30" /> & Lt; / Authentication & gt;
This will indicate the page where the uncertain users will be redirected when they press the controller decorated with [Authorize ()]
in their controller ( This can be done at the action level or at the admin level, at the action level here)
Public category HistoryController: Administrator {... [Authorize] PublicActionMyActionThatNeedAuthentication () {. .} .. ..}
Comments
Post a Comment