共用方式為


MvcServiceCollectionExtensions.AddRazorPages 方法

定義

多載

AddRazorPages(IServiceCollection)

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

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

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

AddRazorPages(IServiceCollection)

來源:
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>)

來源:
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)

適用於