简体   繁体   中英

ASP.NET MVC Web app to REST API

It's more a structural question than a technical one.

I made a classical Web App with ASP.NET MVC. I works well, the server responds with HTML when I send him an URL. Ok.

I now want to make a mobile application (Android) to access the same data. Maybe there is a way to use the controller's methods which already return the objects I'll need.

So the question: Is there a simple way to make a REST API from a ASP.NET MVC WebAPP? Once again, I think that the controller's method will be pretty much the same. It just has to not return HTML but XML for instance.

I'm a newbie in the Web services technologies.

  1. Add webapi project to your solution
  2. Configure web api controllers
  3. Reuse MVVC classes to access database
  4. Return necessary data - webapi will return it in json and in xml (depends how client will consume it)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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