Sunday, July 3, 2022
Techiexpert.com
No Result
View All Result
  • Login
  • Register
Exclusive Videos
  • Tech news
  • Startup news
  • Artificial Intelligence
  • IOT
  • Big Data
  • Cloud
  • Data Analytics
  • Machine Learning
  • Blockchain
  • Social Media
  • Tech news
  • Startup news
  • Artificial Intelligence
  • IOT
  • Big Data
  • Cloud
  • Data Analytics
  • Machine Learning
  • Blockchain
  • Social Media
No Result
View All Result
TechiExpert
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
Understand the difference between AddMvc() and AddMvcCore()
15
SHARES
213
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

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: .NetVisual Studio
Share6Tweet4Share1Pin1

Related Posts

Telemedicine Business
Tech news

Telemedicine or e-medicine: What is it?

Ways Data Analysis has changed customer reward programs
Tech news

Ways Data Analysis has changed customer reward programs

Digital Learning face recognition
Tech news

Here’s why Deep Learning might not be enough for celebrity face recognition

VPS Helps Forex Trading
Tech news

Staying Safe When Trading on a Trading App

Mozilla launches Thinderbird for android
Tech news

Mozilla launches Thinderbird for android

Most Read

  • How to Track Someone’s iPhone by Phone Number?

    How to Track Someone’s iPhone by Phone Number?

    484 shares
    Share 194 Tweet 121
  • Top 5 car automation trends to know

    260 shares
    Share 104 Tweet 65
  • Is Parody Coin investment a Good Investment?

    97 shares
    Share 39 Tweet 24
  • What is windows modules installer ? How to Enable/Disable

    1244 shares
    Share 498 Tweet 311
  • Tips to Reduce Your Website Hosting Costs

    881 shares
    Share 352 Tweet 220
  • How to Track Activities an Instagram account?

    87 shares
    Share 35 Tweet 22

Recent Stories

Doing Cleanup: 5 Types of Links You Should Disavow

Backlinks
Share4Tweet3Share1Pin1

Hyperlocal marketplace Urvann raises Rs. 3 Cr in Seed Round led by IPV

Hyperlocal marketplace Urvann raises Rs. 3 Cr in Seed Round led by IPV
Share5Tweet3Share1Pin2

Does domain extensions impact SEO standards

Does domain extension impact SEO standards
Share5Tweet3Share1Pin2

How Enterprise Blockchain can enable Privacy Preservation

How Enterprise Blockchain can enable Privacy Preservation
Share5Tweet3Share1Pin1
  • Terms of use
  • Privacy Policy
  • About Us
  • Contact us
  • Write For Us
  • Cookie Policy

© 2022 All Rights Reserved

No Result
View All Result
  • Tech news
  • Startup news
  • Artificial Intelligence
  • IOT
  • Big Data
  • Cloud
  • Data Analytics
  • Machine Learning
  • Blockchain
  • Social Media

© 2022 All Rights Reserved

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

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

Log In
Cookie Law Notice
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT