MVC和Asp.net混合应用程序起点

我有一个MVC和Asp.net混合应用程序,我有一个控制器,但没有任何主控制器,我不想从mvc视图启动应用程序,我需要从default.aspx开始 当我在URL末尾写\“ default.aspx \”时,它可以正常工作。但是当我编写mysite.com/时它不起作用 我也有网络服务,但现在无法使用。由于路由类似:\“ mywebservice.asmx / mymethodname \” 如何设置我的global.asax?在此组合中运行需要什么配置?
已邀请:
您可以只在Web应用程序的子文件夹中创建MVC应用程序,然后将任何Global.asax配置移动到WebForms应用程序中 您只需要更新路由,如果您的MVC应用是在名为MVC的文件夹中创建的,则可能看起来像这样:
           routes.MapRoute(
           \"MVC default\",                                              
           \"MVC/default.aspx\",                                         
            new { controller = \"Home\", action = \"Index\", id = \"\" }  
          );

        routes.MapRoute(
           \"Services\",
           \"MVC/{controller}/{action}/{id}\",
           new { controller = \"Home\", action = \"Index\", id = \"\" }
            );
编辑: 实际上,您需要映射以确保您的视图也正确映射,可以通过创建一个快速的自定义视图引擎来做到这一点:
        public class CustomViewEngine : System.Web.Mvc.WebFormViewEngine
{
    public CustomViewEngine()
    {
        base.ViewLocationFormats = new string[]
        {
          \"~/MVC/Views/{1}/{0}.aspx\",
          \"~/MVC/Views/{1}/{0}.ascx\",
          \"~/MVC/Views/Shared/{0}.aspx\",
          \"~/MVC/Views/Shared/{0}.ascx\"
        };

           base.PartialViewLocationFormats = new string[] {
         \"~/MVC/Views/{1}/{0}.aspx\",
          \"~/MVC/Views/{1}/{0}.ascx\",
          \"~/MVC/Views/Shared/{0}.aspx\",
          \"~/MVC/Views/Shared/{0}.ascx\"
        };

           base.MasterLocationFormats = new string[]
        {
          \"~/MVC/Views/{1}/{0}.master\",
          \"~/MVC/Views/Shared/{0}.master\"
        };
    }

}
然后在您的global.asax中注册它:
        System.Web.Mvc.ViewEngines.Engines.Clear();
        System.Web.Mvc.ViewEngines.Engines.Add(new CustomViewEngine());

要回复问题请先登录注册