0
所以我有一個ASP.NET MVC3應用具有以下的web.configMVC3在哪裏重定向未經授權的用戶?
<?xml version="1.0"?>
<configuration>
....
<system.web>
....
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" defaultUrl="~"
slidingExpiration="true" timeout="10080" />
</authentication>
和控制器:
[Authorize(Roles="admin")]
public class MetaStyleController : TunaController
{
....
public ActionResult Index()
{
....
如果我沒有登錄,我試着打http//localhost/myAppPath/MetaStyle
,如上所述,我被重定向到登錄頁面,對嗎?
那麼,爲什麼我會重定向到http://localhost/myAppPath/Account/Login?ReturnUrl=%2fmyAppPath%2fMetaStyle
? (注意,該網址已經登錄而不是LogOn支持)
凡Login
來的呢?我在我的項目中看不到它。
您是否在該URL中看到有效頁面? – jorel
Spender,看看John Galloway的這篇文章是否有幫助:http://weblogs.asp.net/jgalloway/archive/2012/05/04/asp-net-mvc-authentication-customizing-authentication-and-authorization-the- right-way.aspx –
所以我們正在尋找登錄幻象:)我的猜測是在父/子目錄中重疊web.config文件...帳戶/登錄名應該在某處定義... – Tisho