MvcServiceCollectionExtensions.AddRazorPages 方法

定義

多載

AddRazorPages(IServiceCollection)

將頁面的服務加入至指定的 IServiceCollection

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

將頁面的服務加入至指定的 IServiceCollection

AddRazorPages(IServiceCollection)

將頁面的服務加入至指定的 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

IMvcBuilder,可用來進一步設定 MVC 服務。

備註

這個方法會設定頁面常用功能的 MVC 服務。 這會結合 、、 AddAuthorization(IMvcCoreBuilder) AddDataAnnotations(IMvcCoreBuilder)AddCacheTagHelper(IMvcCoreBuilder)AddRazorPages(IMvcCoreBuilder) 的效果 AddMvcCore(IServiceCollection)

若要為 API 的控制器新增服務,請呼叫 AddControllers(IServiceCollection)

若要為具有檢視的控制器新增服務,請呼叫 AddControllersWithViews(IServiceCollection)

適用於

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

將頁面的服務加入至指定的 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

IMvcBuilder,可用來進一步設定 MVC 服務。

備註

這個方法會設定頁面常用功能的 MVC 服務。 這會結合 、、 AddAuthorization(IMvcCoreBuilder) AddDataAnnotations(IMvcCoreBuilder)AddCacheTagHelper(IMvcCoreBuilder)AddRazorPages(IMvcCoreBuilder) 的效果 AddMvcCore(IServiceCollection)

若要為 API 的控制器新增服務,請呼叫 AddControllers(IServiceCollection)

若要為具有檢視的控制器新增服務,請呼叫 AddControllersWithViews(IServiceCollection)

適用於