How was the relationship between Web Api and Asp.NET MVC in Asp.NET 5?

Asked

Viewed 219 times

11

Us ASP.NET 4.6 or less there were differences between Web Api and Asp.Net MVC. O controller, may inherit from controller or of ApiController. However, with the arrival of the Asp.Net 5 will not have but this separation, the difference will be between AddMVC and AddWebApiConventions in services, as said in this article.

It was really unified the two and if that’s the only difference?

  • 1

    He managed to clear up his doubt?

  • 2

    @Denercarvalho I had forgotten this question, Sorry. I created it with informative character and I would put an answer myself but forgot. If you want to answer as well, it would help to have more content on the subject.

1 answer

1

According to information on Scott Haselman’s blog, controllers in the ASP Core were unified, so there are no more classes Controller or ApiController, there is only one Controller returning JSON or Views with HTML and has a unique structure for features such as routes, etc...

The method services.AddWebApiConventions(); should be used to facilitate portability of previous versions of the Web Api, this method is part of the package Microsoft.AspNet.Mvc.WebApiCompatShim containing a class ApiController, this class has a structure that mimics the Web Api of previous versions.

The method services.AddMvc(); adds the basic structure of MVC to the current version of ASP Core.

Sources: https://docs.asp.net/en/latest/migration/webapi.html http://www.hanselman.com/blog/ExploringAMinimalWebAPIWithASPNETCore.aspx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.