【问题标题】:add an ASP.NET MVC project to an existing ASP.NET Web forms application将 ASP.NET MVC 项目添加到现有 ASP.NET Web 窗体应用程序
【发布时间】:2016-06-01 05:20:42
【问题描述】:

如何将 ASP.NET MVC 项目添加到现有的 ASP.NET Web 表单应用程序。如何从现有网站调用 MVC 项目页面。

【问题讨论】:

    标签: asp.net-mvc webforms


    【解决方案1】:

    您可以参考this 分步指南了解如何操作。

    你的问题类似于

    Is it possible to host an asp.net MVC in the same folder as asp.net web forms app?

    【讨论】:

      【解决方案2】:

      我们和你的情况完全一样,而且没有你想象的那么糟糕。感谢 Nuget,这是一个您可以遵循的相当简单的过程,Dave Paquette 在他的blog post

      中描述了如何做到这一点

      一旦你启动并运行了 Mvc,你需要做的就是从 webforms 重定向到 Mvc:

      Response.Redirect("~/Controller/Action/")
      

      您也可以使用 Mvc 路由系统从网络表单中生成路由:

      System.Web.Mvc.UrlHelper url = new System.Web.Mvc.UrlHelper(HttpContexxt.Current.Request.requestContext)
      Response.Redirect(url.Action("Action", "Controller"))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-07-12
        • 2021-04-30
        • 2017-11-29
        • 1970-01-01
        • 2012-08-12
        • 2014-02-23
        • 2014-11-21
        • 2023-03-19
        相关资源
        最近更新 更多