MvcServiceCollectionExtensions.AddRazorPages 方法

定义

重载

AddRazorPages(IServiceCollection)

将页面服务添加到指定的 IServiceCollection

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

将页面服务添加到指定的 IServiceCollection

AddRazorPages(IServiceCollection)

Source:
MvcServiceCollectionExtensions.cs

将页面服务添加到指定的 IServiceCollection

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

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

返回

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

注解

此方法为页面的常用功能配置 MVC 服务。 这结合了 、、AddAuthorization(IMvcCoreBuilder)AddDataAnnotations(IMvcCoreBuilder)AddCacheTagHelper(IMvcCoreBuilder)AddRazorPages(IMvcCoreBuilder)的效果AddMvcCore(IServiceCollection)

若要为 API 的控制器添加服务,请调用 AddControllers(IServiceCollection)

若要为具有视图的控制器添加服务,请调用 AddControllersWithViews(IServiceCollection)

适用于

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

Source:
MvcServiceCollectionExtensions.cs

将页面服务添加到指定的 IServiceCollection

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

参数

services
IServiceCollection

要向其中添加服务的 IServiceCollection

configure
Action<RazorPagesOptions>

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

返回

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

注解

此方法为页面的常用功能配置 MVC 服务。 这结合了 、、AddAuthorization(IMvcCoreBuilder)AddDataAnnotations(IMvcCoreBuilder)AddCacheTagHelper(IMvcCoreBuilder)AddRazorPages(IMvcCoreBuilder)的效果AddMvcCore(IServiceCollection)

若要为 API 的控制器添加服务,请调用 AddControllers(IServiceCollection)

若要为具有视图的控制器添加服务,请调用 AddControllersWithViews(IServiceCollection)

适用于