开发者

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:

http://localhost:1177/CMS/Login

Any idea how to solve this?

Thanks in advance


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜