How to mix WebForms and MVC in ASP.NET

2019-03-12 04:35发布

I have an existing ASP.NET WebForms 3.0 application that works just fine. I upgraded it to ASP.NET 4 and it still works great, but now I want to add some ASP.NET MVC pages to it. I don't want to rewrite the application.

Any suggestions? Can I mix them? How to work it? Any tutorials for me?

2条回答
地球回转人心会变
2楼-- · 2019-03-12 04:50

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

查看更多
我命由我不由天
3楼-- · 2019-03-12 04:56

Take a look at Scott Hanselman's blog article on this very topic:

Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications

查看更多
登录 后发表回答