MvcServiceCollectionExtensions.AddControllersWithViews Метод

Определение

Перегрузки

AddControllersWithViews(IServiceCollection)

Добавляет службы для контроллеров в указанный IServiceCollectionобъект . Этот метод не регистрирует службы, используемые для страниц.

AddControllersWithViews(IServiceCollection, Action<MvcOptions>)

Добавляет службы для контроллеров в указанный IServiceCollectionобъект . Этот метод не регистрирует службы, используемые для страниц.

AddControllersWithViews(IServiceCollection)

Добавляет службы для контроллеров в указанный IServiceCollectionобъект . Этот метод не регистрирует службы, используемые для страниц.

public static Microsoft.Extensions.DependencyInjection.IMvcBuilder AddControllersWithViews (this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddControllersWithViews : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IMvcBuilder
<Extension()>
Public Function AddControllersWithViews (services As IServiceCollection) As IMvcBuilder

Параметры

services
IServiceCollection

Коллекция IServiceCollection, в которую добавляются службы.

Возвращаемое значение

Объект , IMvcBuilder который можно использовать для дальнейшей настройки служб MVC.

Комментарии

Этот метод настраивает службы MVC для часто используемых функций с контроллерами с представлениями. Это объединяет эффекты AddMvcCore(IServiceCollection), AddApiExplorer(IMvcCoreBuilder), AddAuthorization(IMvcCoreBuilder), AddCors(IMvcCoreBuilder), AddDataAnnotations(IMvcCoreBuilder), AddFormatterMappings(IMvcCoreBuilder), AddCacheTagHelper(IMvcCoreBuilder), AddViews(IMvcCoreBuilder)и AddRazorViewEngine(IMvcCoreBuilder).

Чтобы добавить службы для страниц, вызовите AddRazorPages(IServiceCollection).

Применяется к

AddControllersWithViews(IServiceCollection, Action<MvcOptions>)

Добавляет службы для контроллеров в указанный IServiceCollectionобъект . Этот метод не регистрирует службы, используемые для страниц.

public static Microsoft.Extensions.DependencyInjection.IMvcBuilder AddControllersWithViews (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Mvc.MvcOptions> configure);
public static Microsoft.Extensions.DependencyInjection.IMvcBuilder AddControllersWithViews (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Mvc.MvcOptions>? configure);
static member AddControllersWithViews : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Mvc.MvcOptions> -> Microsoft.Extensions.DependencyInjection.IMvcBuilder
<Extension()>
Public Function AddControllersWithViews (services As IServiceCollection, configure As Action(Of MvcOptions)) As IMvcBuilder

Параметры

services
IServiceCollection

Коллекция IServiceCollection, в которую добавляются службы.

configure
Action<MvcOptions>

Действие Action<T> для настройки предоставленного объекта MvcOptions.

Возвращаемое значение

Объект , IMvcBuilder который можно использовать для дальнейшей настройки служб MVC.

Комментарии

Этот метод настраивает службы MVC для часто используемых функций с контроллерами с представлениями. Это объединяет эффекты AddMvcCore(IServiceCollection), AddApiExplorer(IMvcCoreBuilder), AddAuthorization(IMvcCoreBuilder), AddCors(IMvcCoreBuilder), AddDataAnnotations(IMvcCoreBuilder), AddFormatterMappings(IMvcCoreBuilder), AddCacheTagHelper(IMvcCoreBuilder), AddViews(IMvcCoreBuilder)и AddRazorViewEngine(IMvcCoreBuilder).

Чтобы добавить службы для страниц, вызовите AddRazorPages(IServiceCollection).

Применяется к