MvcServiceCollectionExtensions.AddControllersWithViews 方法

定义

重载

AddControllersWithViews(IServiceCollection)

将控制器的服务添加到指定的 IServiceCollection。 此方法不会注册用于页面的服务。

AddControllersWithViews(IServiceCollection, Action<MvcOptions>)

将控制器的服务添加到指定的 IServiceCollection。 此方法不会注册用于页面的服务。

AddControllersWithViews(IServiceCollection)

Source:
MvcServiceCollectionExtensions.cs

将控制器的服务添加到指定的 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 服务。 这结合了 、、、AddApiExplorer(IMvcCoreBuilder)AddDataAnnotations(IMvcCoreBuilder)AddFormatterMappings(IMvcCoreBuilder)AddCors(IMvcCoreBuilder)AddCacheTagHelper(IMvcCoreBuilder)AddAuthorization(IMvcCoreBuilder)AddViews(IMvcCoreBuilder)AddRazorViewEngine(IMvcCoreBuilder)的效果。AddMvcCore(IServiceCollection)

若要为页面添加服务,请调用 AddRazorPages(IServiceCollection)

适用于

AddControllersWithViews(IServiceCollection, Action<MvcOptions>)

Source:
MvcServiceCollectionExtensions.cs

将控制器的服务添加到指定的 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>

用于配置所提供的 MvcOptionsAction<T>

返回

可用于 IMvcBuilder 进一步配置 MVC 服务的 。

注解

此方法为具有视图的控制器的常用功能配置 MVC 服务。 这结合了 、、、AddApiExplorer(IMvcCoreBuilder)AddDataAnnotations(IMvcCoreBuilder)AddFormatterMappings(IMvcCoreBuilder)AddCors(IMvcCoreBuilder)AddCacheTagHelper(IMvcCoreBuilder)AddAuthorization(IMvcCoreBuilder)AddViews(IMvcCoreBuilder)AddRazorViewEngine(IMvcCoreBuilder)的效果。AddMvcCore(IServiceCollection)

若要为页面添加服务,请调用 AddRazorPages(IServiceCollection)

适用于