Sunday, April 11, 2021
Techiexpert.com
No Result
View All Result
  • Login
  • Register
  • Home
  • Tech news
  • Startups
  • AI
  • IOT
  • Big Data
  • Cloud
  • Data Analytics
  • ML
  • Blogging
Techiexpert.com
No Result
View All Result

Understand the difference between AddMvc() and AddMvcCore()

Chirag by Chirag
December 7, 2018
in Tech news
Reading Time: 3 mins read
A A
0
Understand the difference between AddMvc() and AddMvcCore()
15
SHARES
221
VIEWS
Share on FacebookShare on Twitter

In this article, we are discussing the differences between AddMVC () and AddMvc Core (). As a beginner in the .NET language, you must have stumbled upon these two methods in the configure services () of the startup class.

Both the methods look quite similar and their respective help tooltips simply tell us this:

Adds MVC services to the specified IService Collection

Adds essential MVC services to the specified to the specified Iservice Collection

ADVERTISEMENT

While creating an Asp.net development services in India, you usually see a Startup.cs file to configure your services and configure your pipeline. Configure services is preparing for your services for being used as you configure them. .NET Core is a modular rewrite of the .NET cross-platform framework. This new framework comes with so many amazing features that make it popular across regions. One of the best features we can talk about this framework is Dependency Injection. It’s like everything is on demand and you have to enable whatever you need.

This is the place to add dependency injection, but that is a different topic. Dependency Injection is a unique design pattern in which a class or object has its dependent classes injected rather than creating them directly. It facilitates loose coupling and promotes testability and maintenance. It also allows you to change your implementation without changing the classes or interfaces that leverage those implementations.

You can have a lot of configuration here but we want to focus on the main topic, that means adding the MVC framework.

AddMvcCore Method

AddMvcCore is an extension method on the IService Collection in the MVC framework. Using an extension method is the most common pattern for registering groups of related services into the service collection. Same goes for this extension method and this can be used to register the MVC series that the more commonly when building the MVC application. This extension method is very useful when your application is not taking advantage of all MVC features.

In the visual studio, when we start with “File” – “New Project” the default setting in the method is AddMvC(). And it works straight away. When building the REST APIs, here, there is no need for Razor components, we often start with AddMvcCore, which makes the process more contemporary.

By adding this method, it enables the minimum dependency needed to run the MVC framework. AddMvcCore method adds significant MVC series to the specified method.

Features of this method:

Application Part manager: It manages the parts and features of an MVC application.

Default Feature Provider: This feature adds the controller feature providers.

Default services: This feature is used to add the routing.

Core Services: These are basic services to run the MVC framework with comparatively minimum dependencies.

AddMvc Method

If you want to use the MVC framework, firstly you have to enable or you have to take the MVC project template. This method adds all dependencies in the specified project. This method first calls the AddMvcCore extension. Due to this reason, all of the same setup and service registration occurs, including the creation of an application manager.

Key features of this method:

API Explorer: Enables the API help pages.

Authorization: Used for the security and authorization of web pages, which is a very important feature.

MVC Core: This is the core dependency of the MVC framework and they are required to run the MVC framework with minimum dependencies.

Default Framework parts: It adds some application part dependencies. The application part manager takes care of application parts and application features.

Formatter Mappings: A filter will use the format value in the route data or query string to set the content type on an object result.

Views: By the help of this feature, you can see views feature and makes it work and makes the functionality better.

Cache tag Helper: Cache Tag helpers enables server-side code to participate in creating and rendering HTML elements in Razor files.

Razor View engine: Parser and code generator for CSHTML files are used in view pages for MVC web apps.

Cors: This feature enables the cross-origin resource sharing (CorS) which is a mechanism that allows to restrict resources and allows them to use in a convenient way.

Summary

If we compare both the extension method, the AddMvcCore method, which laid more groundwork by creating the Application Part manager. Generally, we call extensions to register extra services. As you can see in this article, many of those services are more specific to web applications which need to work with views. For API only applications, it is quite possible you won’t need most of these. In the API projects, we start with AddMvcCore and simply add in the few items we need to use the builder extension methods and complete the intended tasks.

Tags: .Net CoreVisual Studio
Share6Tweet4Share1Pin1
Chirag

Chirag

Software Programmer 

Related Posts

Microsoft Teams is coming under Government Community Cloud
Tech news

COVID accelerated a push to the Microsoft cloud. Top reason: Microsoft Teams — ShareGate Report

by Srikanth
April 10, 2021
Microsoft new gaming device powered by Azure
Tech news

Digitate’s ignio™ AIOps For Azure Now Available in the Microsoft Azure Marketplace

by Srikanth
April 8, 2021
Four Practical Applications Of Artificial Intelligence And 5G
Tech news

Four Practical Applications Of Artificial Intelligence And 5G

by Srikanth
April 7, 2021
Demographic Data
Tech news

How Can Demographic Data Be Used to target a market effectively?

by Sony T
April 7, 2021
Could we see online casinos utilize new technologies further?
Tech news

Could we see online casinos utilize new technologies further?

by Sony T
April 7, 2021

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I agree to the Terms & Conditions and Privacy Policy.

Latest Stories

Microsoft Teams is coming under Government Community Cloud
Tech news

COVID accelerated a push to the Microsoft cloud. Top reason: Microsoft Teams — ShareGate Report

by Srikanth
April 10, 2021
PumPumPum
Startup news

PumPumPum raises INR 5.5 Cr in Pre-Series A funding led by IPV

by Sony T
April 9, 2021
Social Platform for Positive Impact – ChekMarc
Startup news

Social Platform for Positive Impact – ChekMarc

by Srikanth
April 8, 2021
Microsoft new gaming device powered by Azure
Tech news

Digitate’s ignio™ AIOps For Azure Now Available in the Microsoft Azure Marketplace

by Srikanth
April 8, 2021
Load More
Techiexpert.com

© 2020 All Rights Reserved

  • Terms of use
  • Privacy Policy
  • About Us
  • Contact us
  • Write For Us
  • Cookie Policy

  • Login
  • Sign Up
No Result
View All Result
  • Home
  • Tech news
  • Startups
  • AI
  • IOT
  • Big Data
  • Cloud
  • Data Analytics
  • ML
  • Blogging

© 2020 All Rights Reserved

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

*By registering into our website, you agree to the Terms & Conditions and Privacy Policy.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.
Newsletter ?

What is Expected ?

  • Newsletter
  • eBooks
  • Tech Reports
  • Infographic
  • Webinar
  • Event Tickets
We would like to show you notifications for the latest news and updates.
Dismiss
Allow Notifications