0
我試圖在我的web應用程序中設置路由。路由和Ninject給出404
但是它似乎不適用於Ninject。如果我在Global.asax中評論所有的Ninject,這條路線就像一個魅力。
在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>
任何人都有可能是錯誤的想法?