Share via


MvcServiceCollectionExtensions.AddControllersWithViews Metode

Definisi

Overload

AddControllersWithViews(IServiceCollection)

Menambahkan layanan untuk pengontrol ke yang ditentukan IServiceCollection. Metode ini tidak akan mendaftarkan layanan yang digunakan untuk halaman.

AddControllersWithViews(IServiceCollection, Action<MvcOptions>)

Menambahkan layanan untuk pengontrol ke yang ditentukan IServiceCollection. Metode ini tidak akan mendaftarkan layanan yang digunakan untuk halaman.

AddControllersWithViews(IServiceCollection)

Menambahkan layanan untuk pengontrol ke yang ditentukan IServiceCollection. Metode ini tidak akan mendaftarkan layanan yang digunakan untuk halaman.

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

Parameter

services
IServiceCollection

untuk IServiceCollection menambahkan layanan.

Mengembalikan

Yang IMvcBuilder dapat digunakan untuk mengonfigurasi layanan MVC lebih lanjut.

Keterangan

Metode ini mengonfigurasi layanan MVC untuk fitur yang umum digunakan dengan pengontrol dengan tampilan. Ini menggabungkan efek dari AddMvcCore(IServiceCollection), , AddAuthorization(IMvcCoreBuilder)AddApiExplorer(IMvcCoreBuilder), AddCors(IMvcCoreBuilder), AddDataAnnotations(IMvcCoreBuilder), AddFormatterMappings(IMvcCoreBuilder), AddCacheTagHelper(IMvcCoreBuilder), AddViews(IMvcCoreBuilder), dan AddRazorViewEngine(IMvcCoreBuilder).

Untuk menambahkan layanan untuk panggilan AddRazorPages(IServiceCollection)halaman .

Berlaku untuk

AddControllersWithViews(IServiceCollection, Action<MvcOptions>)

Menambahkan layanan untuk pengontrol ke yang ditentukan IServiceCollection. Metode ini tidak akan mendaftarkan layanan yang digunakan untuk halaman.

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

Parameter

services
IServiceCollection

untuk IServiceCollection menambahkan layanan.

configure
Action<MvcOptions>

Action<T> untuk mengonfigurasi yang disediakanMvcOptions.

Mengembalikan

Yang IMvcBuilder dapat digunakan untuk mengonfigurasi layanan MVC lebih lanjut.

Keterangan

Metode ini mengonfigurasi layanan MVC untuk fitur yang umum digunakan dengan pengontrol dengan tampilan. Ini menggabungkan efek dari AddMvcCore(IServiceCollection), , AddAuthorization(IMvcCoreBuilder)AddApiExplorer(IMvcCoreBuilder), AddCors(IMvcCoreBuilder), AddDataAnnotations(IMvcCoreBuilder), AddFormatterMappings(IMvcCoreBuilder), AddCacheTagHelper(IMvcCoreBuilder), AddViews(IMvcCoreBuilder), dan AddRazorViewEngine(IMvcCoreBuilder).

Untuk menambahkan layanan untuk panggilan AddRazorPages(IServiceCollection)halaman .

Berlaku untuk