MvcServiceCollectionExtensions.AddMvc Method

Definition

Overloads

AddMvc(IServiceCollection)

Adds MVC services to the specified IServiceCollection.

AddMvc(IServiceCollection, Action<MvcOptions>)

Adds MVC services to the specified IServiceCollection.

AddMvc(IServiceCollection)

Source:
MvcServiceCollectionExtensions.cs
Source:
MvcServiceCollectionExtensions.cs
Source:
MvcServiceCollectionExtensions.cs

Adds MVC services to the specified IServiceCollection.

C#
public static Microsoft.Extensions.DependencyInjection.IMvcBuilder AddMvc (this Microsoft.Extensions.DependencyInjection.IServiceCollection services);

Parameters

services
IServiceCollection

The IServiceCollection to add services to.

Returns

An IMvcBuilder that can be used to further configure the MVC services.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

AddMvc(IServiceCollection, Action<MvcOptions>)

Source:
MvcServiceCollectionExtensions.cs
Source:
MvcServiceCollectionExtensions.cs
Source:
MvcServiceCollectionExtensions.cs

Adds MVC services to the specified IServiceCollection.

C#
public static Microsoft.Extensions.DependencyInjection.IMvcBuilder AddMvc (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Mvc.MvcOptions> setupAction);

Parameters

services
IServiceCollection

The IServiceCollection to add services to.

setupAction
Action<MvcOptions>

An Action<T> to configure the provided MvcOptions.

Returns

An IMvcBuilder that can be used to further configure the MVC services.

Applies to

ASP.NET Core 9.0 and other versions
Product Versions
ASP.NET Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0