Маршрутизация и Ninject с веб-формами - PullRequest
0 голосов
/ 02 ноября 2011

Я пытаюсь настроить маршрутизацию в моем веб-приложении.

Однако, похоже, он не работает с Ninject в моем Global.asax, но если я прокомментирую все Ninject в моем Global.asax, маршрут будет работать как шарм.

С Ninject в файле я просто получаю 404 "Ресурс не найден" при попытке открыть страницу маршрута.

Вот что в моем коде Global.asax:

<%@ Application Language="C#" Inherits="Ninject.Web.NinjectHttpApplication" %>
<%@ Import Namespace="Infrastructure.Storage" %>
<%@ Import Namespace="Ninject" %>
<%@ Import Namespace="Ninject.Modules" %>
<%@ Import Namespace="System.Web.Routing" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }

    protected override IKernel CreateKernel()
    {
        IKernel kernel = new StandardKernel(new SiteModule());
        return kernel;
    }

    public class SiteModule : NinjectModule
    {
        public override void Load()
        {
            //Bind<ILogger>().To<NLogger>().InSingletonScope();
            //Bind<IAuthentication>().To<Authentication>();
            Bind<ISession>().To<LinqToSqlSession>();
            Bind<IReadOnlySession>().To<LinqToSqlReadOnlySession>();
            //Bind<IReporting>().To<LinqToSqlReporting>();
        }
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("City", "Cities/{id}", "~/test2.aspx");
    }

</script>

У кого-нибудь есть идея, что может быть не так? Буду очень признателен.

С уважением Martin

...