使用51Degrees.mobi重定向到MVC Mobile Area时出错

时间:2011-02-23 13:52:22

标签: asp.net-mvc-2 mobile-website

我是MVC的新手。我写的应用程序有效,我不断对它进行微调。最近,我一直在玩弄移动网站工具。我从来不需要这样做,所以我尽可能多地搜索/阅读/修补。我开始使用Microsoft Web App Toolkit,最终有点过时,所以我继续阅读并最终切换到使用51Degrees.mobi库。

我根据几个不同的帖子进行了设置:

  1. Steve Sanderson - http://www.asp.net/learn/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application
  2. 51Degrees用户指南 - http://51degrees.codeplex.com/wikipage?title=User%20guide
  3. ......以及一系列其他网站和描述都围绕着相同的基本点。
  4. 所以这就是桑德森先生所描述的。

    • 为我的Mobile控制器/视图创建了一个MVC区域,后者又创建了MobileAreaRegistration.cs文件

    Area - Mobile

    • 修改了该区域下的MobileAreaRegistration.cs以指定默认控制器和操作。

    enter image description here

    • 在我的配置文件中包含51Degrees组件。即sectionGroup引用,包含重定向和httpModule的fiftyOne部分。 enter image description here

    即使我使用Win7,我也必须使用以下IIS模块进行调试: enter image description here

    我还对Global.asax.cs文件进行了必要的修改,以包含主命名空间,这样就不会混淆应用程序在执行时应该默认的区域。 (正如史蒂夫桑德森的帖子中所述)。

    最后,我安装了一个iphone模拟器和android模拟器,重定向的代码在我的HomeController中。我的每个设备都没有具体的内容。我仍然试图让重定向正确启动。

    enter image description here

    当我在桌面浏览器中运行该站点时(没有移动重定向),它运行正常。当我使用模拟器(或尝试将桌面浏览器定向到移动网站)时,我收到以下错误。这看起来很明显(MISSING CONTROLLER),但它就在那里。那么我没看到什么?

    找不到请求的页面。 (404)

    System.Web.HttpException:未找到路径'/ Mobile'的控制器或未实现IController。在System.Web.Mvc.DevaultControllerFactory.GetControllerInstance(RequestContext requestContext,Type controllerType)中的System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext,String controllerName)at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext,IController& System.Web上的System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext,AsyncCallback回调,对象状态)中的System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext,AsyncCallback回调,对象状态)处理器,IControllerFactory& factory) System.Web.HttpApplication.ExecuteStep上的System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()中的.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context,AsyncCallback cb,Object extraData) (IExecutionStep step,Boolean& completedSynchronously)

    第二组眼睛会很棒!在此先感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

回答!

问题不在于移动工具和重定向的配置,而在于区域本身的移动部分的命名空间。

我的移动区控制器中的命名空间是Licensing.Web.Mobile.Controllers。他们需要是Licensing.Web。区域 .Mobile.Controllers。

一旦我将“区域”添加到命名空间,它就像一个冠军。

我发现了更多的东西:Asp.NET MVC 2 and 404