Why is not enought to just add app.UseMvc() in the Configuration method in a mvc6 application? why it is also necessary to add the services.AddMvc() in the ConfigureServices method? and where can I find more info about this?
Thank you.
In this new ASP.NET 5 world there are two primary aspects of app development.
Due to these two primary concerns there then happens to be two mechanisms for tying into the system.
First, UseMVC
is the way your application can say I want MVC to take a part in the request handling stage at "this" point. It's essentially a shortcut to an MVC specific middleware.
Second, AddMvc
is the way your application says that you want the MVC services available to the system (needed in order for UseMvc
) to work correctly. Therefore, if you were to try and do UseMvc
without adding the corresponding MVC services the call would throw. Note that this adds the appropriate MVC services to the DI container.
Hopefully this answered your questions, for more information on it you can check out http://www.asp.net/vnext for more general information. For something more specific/video I did a talk a while back at Orchard conference where I go over several of the core pieces https://www.youtube.com/watch?v=kqgIByKn9Wk
Note: I gave the talk a while back, some concepts are outdated/may have changed but the core concepts are the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With