Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

MvcServiceCollectionExtensions.AddRazorPages Method

Definition

Namespace:
Microsoft.Extensions.DependencyInjection
Assembly:
Microsoft.AspNetCore.Mvc.dll
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
AddRazorPages(IServiceCollection)

Adds services for pages to the specified IServiceCollection.

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

Adds services for pages to the specified IServiceCollection.

AddRazorPages(IServiceCollection)

Source:
MvcServiceCollectionExtensions.cs

Adds services for pages to the specified 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

Parameters

services
IServiceCollection

The IServiceCollection to add services to.

Returns

An IMvcBuilder that can be used to further configure the MVC services.

Remarks

This method configures the MVC services for the commonly used features for pages. This combines the effects of AddMvcCore(IServiceCollection), AddAuthorization(IMvcCoreBuilder), AddDataAnnotations(IMvcCoreBuilder), AddCacheTagHelper(IMvcCoreBuilder), and AddRazorPages(IMvcCoreBuilder).

To add services for controllers for APIs call AddControllers(IServiceCollection).

To add services for controllers with views call AddControllersWithViews(IServiceCollection).

Applies to

AddRazorPages(IServiceCollection, Action<RazorPagesOptions>)

Source:
MvcServiceCollectionExtensions.cs

Adds services for pages to the specified 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

Parameters

services
IServiceCollection

The IServiceCollection to add services to.

configure
Action<RazorPagesOptions>

An Action<T> to configure the provided MvcOptions.

Returns

An IMvcBuilder that can be used to further configure the MVC services.

Remarks

This method configures the MVC services for the commonly used features for pages. This combines the effects of AddMvcCore(IServiceCollection), AddAuthorization(IMvcCoreBuilder), AddDataAnnotations(IMvcCoreBuilder), AddCacheTagHelper(IMvcCoreBuilder), and AddRazorPages(IMvcCoreBuilder).

To add services for controllers for APIs call AddControllers(IServiceCollection).

To add services for controllers with views call AddControllersWithViews(IServiceCollection).

Applies to


Feedback

Was this page helpful?