asp.net mvc 2 Change redirection of unauthorized actions
Solution is called Portal which holds Areas/CMS/Login folder inside it. Login controller in CMS/Controllers is almost the same as AccountController in Portal solution. I customized Login and it works all fine except one thing: 开发者_开发知识库When I use [Authorize]
filter and If user is not logged in than he is redirected to http://localhost:1177/Account/LogOn?ReturnUrl=%2fCMS%2fArticle and I would like that redirection takes user to here:
Your web.config will probably contain a portion that looks like this:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880"/>
</authentication>
It is the loginUrl that defines where the AuthorizeAttribute redirects you to when the user is not authorized yet. The return url that is passed into the action is what you can use to redirect the user back to once he is authorized.
精彩评论