Combine classic ASP.NET and ASP.NET MVC within one

2019-03-15 20:29发布

问题:

We currently have a classic ASP.NET web application which serves as our API. It basically has a bunch of ASMX Web Services, but these are really cumbersome to work with from JavaScript. What I want is to expose a set of RESTful endpoints, but doing this in classis ASP.NET is not what I really want to do.

I'm considering to combine both classic ASP.NET and ASP.NET MVC in one web app. Is this possible at all? If yes, what are the issues/problems I may encounter?

回答1:

Aha! It seems that this is very much possible. Here's a comprehensive article which describes what should be done.



回答2:

An ASP.NET Webforms application can become ASP.NET MVC enabled by following some simple steps,its quite easy infact see this link if you want to go rest for mvc heres a article Rest for mvc by Phil Haack and Rest like nature of MVC heres a comparison Rest in asp net vs wcf



回答3:

The whole goal of routing is to break the one-to-one association between URLs and files in the server’s file system. However, the routing system still does check the file system to see if an incoming URL happens to match a file or disk, and if so, routing ignores the request (bypassing any route entries that the URL might also match) so that the file will be served directly.

So, to answer on a part of your question "is this possible at all": Yes, because routing system will recognize the .asmx file on the file system and it will process it in classic asp.net web services manner.

For the second question I'm not sure because I haven't been doing anything complex with web service inside of the asp.net mvc application.