2011-09-14 39 views
1

我有一個在Visual Studio中工作的MVC3應用程序,但是當發佈到Web服務器時,會在請求的URL上返回404:/ App/Account/LogOn。問題是我從來沒有創建一個帳戶控制器或操作LogOn。我不知道爲什麼帳戶/登錄甚至加載或如何解決它。謝謝。404與ASP.net MVC3和ninject.web.mvc

我的global.asax.cs文件看起來像這樣:

public class MvcApplication : NinjectHttpApplication 
{ 
    public static void RegisterGlobalFilters(GlobalFilterCollection filters) 
    { 
     //filters.Add(new HandleErrorAttribute()); 
    } 

    public static void RegisterRoutes(RouteCollection routes) 
    { 
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

     routes.MapRoute(
      "Default", 
      "{controller}/{action}/{id}", 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
     ); 

    } 

    // Create ninject kernel 
    protected override IKernel CreateKernel() 
    { 
     var kernel = new StandardKernel(); 
     // Add bindings 
     kernel.Bind<IEmployeeRepository>().To<EFEmployeeRepository>(); 
     kernel.Bind<IDocumentRepository>().To<DocumentRepository>(); 
     // Load kernel 
     kernel.Load(Assembly.GetExecutingAssembly()); 
     return kernel; 
    } 

    // Replaces App_Start() when using Ninject 
    protected override void OnApplicationStarted() 
    { 
     base.OnApplicationStarted(); 
     AreaRegistration.RegisterAllAreas(); 
     RegisterGlobalFilters(GlobalFilters.Filters); 
     RegisterRoutes(RouteTable.Routes); 
    } 
} 

回答

1

我最好的猜測是,這是從你的web.config的到來,因爲這是默認的登錄頁面,當你創建一個新的MVC項目。當您嘗試點擊應用了[Authorize]屬性的操作時,它將被重定向到哪裏。

檢查一節,說:

<authentication mode="Forms"> 
     <forms loginUrl="~/Account/LogOn" timeout="2880" /> 
    </authentication> 

如果你有你需要在這裏的網址,否則,如果你不使用安全性您自己的登錄頁面,然後檢查攜帶的行動[Authorize]屬性。

+0

Doh! - 謝謝=) – decompiled