Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

WebAPI: why does it use MVC namespace and classes?

$
0
0

Hello,

I'm pretty new to the WebAPI world.

So far I've read some great articles on how to create and call WebAPI; however, I'm still a bit puzzled about one thing: even if we create "just" a WebAPI, not a MVC application, we are almost "stuck" with theMicrosoft.AspNetCore.Mvc namespace.

For instance:

  • ControllerBase is part of the namespace;
  • HttpMethodAttribute (HttpGet, HttpPost, etc.) is part of the namespace;
  • even return methods like Ok(), CreatedAtRoute(), etc. are part of the namespace.

Why is this like that? Can't we have a "proper" separation between "pure WebAPI" and MVC application? Is that the correct way of doing thing? If no, what is the correct way of creating a "pure WebAPI"?

Thanks and have a nice day :).


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>