如何在MVC中查看aspx webform [英] How do I view a aspx webform in MVC
本文介绍了如何在MVC中查看aspx webform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在mvc中渲染一个简单的webform。我使用--- http:// localhost:29531 / home / chart.aspx调用webform(图表),但它在页面上抛出了一个 - HTTP 404错误。
这就是我在global.aspx路由方法中的含义:
I am trying to render a simple webform in mvc. I calling the webform(chart) using --- http://localhost:29531/home/chart.aspx, but its throwing a -- HTTP 404 error on the page.
This is what I have in my global.aspx routing method:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapPageRoute(
routeName: "Default/",
routeUrl: "Default/{Home}/{chart}",
physicalFile: "~/Views/{Home}/{chart}.aspx"
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
请注意以上代码中我可能遗漏的任何内容。非常感谢。
Please advice, on anything I maybe missing from the above code. Many thanks.
推荐答案
从这里: http://stackoverflow.com/questions/11337477/how-to-mix-webforms-and-mvc-in-asp-net
你必须在MVC应用程序的Global.asax文件中提到这行代码。
routes.IgnoreRoute({WebPage } .aspx / {* pathInfo});
这会禁用扩展名为.aspx的文件的MVC路由
From here: http://stackoverflow.com/questions/11337477/how-to-mix-webforms-and-mvc-in-asp-net
You have to mention this line of code in the Global.asax file in the MVC application.
routes.IgnoreRoute("{WebPage}.aspx/{*pathInfo}");
This disables the MVC routing for the files of extension .aspx
这篇关于如何在MVC中查看aspx webform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文