asp.net-mvc-2 – 从.NET MVC 1迁移到MVC 2 RC
发布时间:2020-12-16 06:52:44 所属栏目:asp.Net 来源:网络整理
导读:我已将MVC1项目迁移到MVC2 RC,现在该站点根本不起作用.我收到错误“找不到入口点”. 我在this link之后迁移了这个项目 我正在使用Castle Windsor作为DI. 这是global.asax.cs的一部分 public static void RegisterRoutes(RouteCollection routes) { routes.Ig
我已将MVC1项目迁移到MVC2 RC,现在该站点根本不起作用.我收到错误“找不到入口点”.
我在this link之后迁移了这个项目 我正在使用Castle Windsor作为DI. 这是global.asax.cs的一部分 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default","{controller}/{action}/{id}",new { controller = "Main",action = "Index",id = "" }); } protected void Application_Start() { log4net.Config.XmlConfigurator.Configure(); InitializeServiceLocator(); //RouteConfigurator.RegisterRoutesTo(RouteTable.Routes); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); Bootstrapper.BootStrap(); } /// <summary> /// If you need to communicate to multiple databases,you'd add a line to this method to /// initialize the other database as well. /// </summary> private void InitializeNHibernateSession() { var cfg = NHibernateSession.Init( webSessionStorage,new string[] { Server.MapPath("~/bin/Edi.Advance.EPortfolio.Data.dll") },new AutoPersistenceModelGenerator().Generate(),Server.MapPath("~/hibernate.cfg.xml")).AddAssembly(typeof(ISoftDeletable).Assembly).AddAssembly( typeof(Action).Assembly); //cfg.SetListener(ListenerType.Delete,new AdvanceDeleteEventListener(IoC.Resolve<ISecurityContextService>())); //cfg.SetListener(ListenerType.SaveUpdate,new AdvanceSaveUpdateEventListener(IoC.Resolve<ISecurityContextService>())); } /// <summary> /// Instantiate the container and add all Controllers that derive from /// WindsorController to the container. Also associate the Controller /// with the WindsorContainer ControllerFactory. /// </summary> protected virtual void InitializeServiceLocator() { // AddComponentsToIoC(); var container = new WindsorContainer(); ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container)); container.RegisterControllers(typeof(MainController)); ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container)); } MainController非常简单,Index动作只返回“Hello World from MVC2”字符串. (没有观点这个动作). 有趣的是,如果我注释掉这一行: ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container)); MainController工作正常,但是由于其他更复杂的控制器不起作用,说没有无参数构造函数. 所以它接缝是WindsorControllerFactory的错误. 有任何想法吗? 解决方法
使用:
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext,Type controllerType) Insted:protected override IController GetControllerInstance(Type controllerType) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 将自定义类添加到HttpContext
- asp.net-mvc – 如何将复杂对象传递给ASP.NET MVC中的另一个
- asp.net – 哪里是.ASPXAUTH cookie
- asp.net-mvc-5 – EntityFramework.SqlServer.dll中出现’S
- asp.net – 如何使用CSS垂直向下移动div
- asp.net-mvc – ASP.NET MVC:路由中的命名空间
- asp.net – 进度条不是一个功能
- 如何在ASP.NET中使用多个授权方案发布相应的承载和Cookie标
- asp.net-mvc – 从ASP.NET MVC中的部分视图中删除逻辑
- asp.net-mvc – 在MVC3中渲染导航
推荐文章
站长推荐
- asp.net – 在自托管Web应用程序中使用性能计数器
- asp.net – 如何在C#2.0中的Web.config中加密用户
- 如何调查ASP.net应用程序上的SQL Server超时错误
- asp.net-mvc – 追加?param =到mvc路由
- 代码“Request.Headers.Range”不能在asp.net核心
- asp.net – 替代SSRS前端
- asp.net-mvc – 使用MVC3剃刀的ASP.Net图表控件
- asp.net-mvc – 尝试继承RegularExpressionAttri
- 剃刀 – 我应该在哪里包含视图组件的脚本?
- asp.net-mvc-3 – 如何增加会话超时MVC 3
热点阅读