简体   繁体   中英

Web APi Vs MVC and Serving static files in ASP.net core Web APi

We have an ASP.net MVC app, and we are seeking to migrate it to ASP.net CORE due to client needs. Actually the app is providing REST services that are consumed by an AngularJS client app served by the same ASP.net app, it's little a mess actually. What should i opt for, Web API or MVC ? and if I choose Web API, can it serve static files ?

Thanks in advance!

First of all, Web Api and MVC is merge in ASP.NET Core.

To setup a solution which can run static files

  1. Enable static files in the Configure method in the Startup.cs class, add:

     app.UseStaticFiles(); 
  2. Add the frontend solution (angularjs files, html etc) to the wwwroot folder.

  3. Remove the default launchUrl ( Properties/launchSettings.json ) and set it to an empty string which will make the web server to look for the index.html file in the root instead

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