开发者

404 with ASP.net MVC3 and ninject.web.mvc

I have an MVC3 application that works in Visual Studio, but when published to the web server returns a 404 on Requested URL: /App/Account/LogOn. The problem is I never created an Account controller or the action LogOn. I'm not sure why Account/LogOn is even loading or how to fix it. Thanks.

My global.asax.cs file looks like this:

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);
    }
}


My best guess would be that this is coming from your web.config, as this is the default login page when you create a new MVC project. Its where you get redirected when you try to hit an action that has the [Authorize] attribute applied to it.

Check for a section that says:

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

If you have your own login page you need to at that URL here, otherwise, if you aren't using security, then check for actions that carry the [Authorize] attribute.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜