简体   繁体   English

ASP.NET MVC 5和Web表单的结合

[英]ASP.NET MVC 5 and Web forms combined

I'm using a combined ASP.NET application. 我正在使用组合的ASP.NET应用程序。 The first website was made with webforms and the added functionality (secondary) website is made with MVC 5. 第一个网站是使用Webforms创建的,而附加功能(辅助)网站是使用MVC 5创建的。

I have one page that I need in both websites and this was made in Webforms (.aspx). 我在两个网站上都有一个页面,这是用Webforms(.aspx)制作的。 I want to use the same functionality in the MVC website. 我想在MVC网站中使用相同的功能。

I made the following: 我做了以下事情:

Controller: 控制器:

    public ActionResult Test()
    {
        return View();
    }

View: 视图:

<h1>@ViewBag.Title</h1>
<iframe src="~/Webpages/test.aspx" frameborder="0" height="550" width="900"></iframe>

The webforms page uses a MasterPage. Webforms页面使用MasterPage。 If I am in the MVC website I will use a blank MasterPage. 如果我在MVC网站中,则将使用空白的MasterPage。

This is working well but I don't know if this is the best solution. 这运作良好,但我不知道这是否是最佳解决方案。 The webforms page is loading a bit slower than the original page. Webforms页面的加载速度比原始页面慢。

You are not need to use iframes in this situation. 在这种情况下,您无需使用iframe。 Just you can copy your design in view, logic in controller.. Then you can get your solution.. I will prefer you Razor view. 只是您可以在视图中复制您的设计,在控制器中复制逻辑。然后您可以得到解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM