Repository navigation
Expand file tree
/
Copy pathSpaApplicationBuilderExtensions.cs
More file actions
49 lines (47 loc) · 2.13 KB
/
Copy pathSpaApplicationBuilderExtensions.cs
File metadata and controls
49 lines (47 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.SpaServices;
using System;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides extension methods used for configuring an application to
/// host a client-side Single Page Application (SPA).
/// </summary>
public static class SpaApplicationBuilderExtensions
{
/// <summary>
/// Handles all requests from this point in the middleware chain by returning
/// the default page for the Single Page Application (SPA).
///
/// This middleware should be placed late in the chain, so that other middleware
/// for serving static files, MVC actions, etc., takes precedence.
/// </summary>
/// <param name="app">The <see cref="IApplicationBuilder"/>.</param>
/// <param name="urlPrefix">
/// The URL path, relative to your application's <c>PathBase</c>, from which the
/// SPA files are served.
///
/// For example, if your SPA files are located in <c>wwwroot/dist</c>, then
/// the value should usually be <c>"dist"</c>, because that is the URL prefix
/// from which browsers can request those files.
/// </param>
/// <param name="defaultPage">
/// Optional. If specified, configures the path (relative to <paramref name="urlPrefix"/>)
/// of the default page that hosts your SPA user interface.
/// If not specified, the default value is <c>"index.html"</c>.
/// </param>
/// <param name="configure">
/// Optional. If specified, this callback will be invoked so that additional middleware
/// can be registered within the context of this SPA.
/// </param>
public static void UseSpa(
this IApplicationBuilder app,
string urlPrefix,
string defaultPage = null,
Action configure = null)
{
new SpaDefaultPageMiddleware(app, urlPrefix, defaultPage, configure);
}
}
}