-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
39 lines (30 loc) · 1 KB
/
Program.cs
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
using aspnet_hotwire.Hubs;
using aspnet_hotwire.Services;
using Microsoft.Extensions.FileProviders;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
builder.Services.AddHttpContextAccessor();
builder.Services.AddTransient<IRazorPartialToStringRenderer, RazorPartialToStringRenderer>();
builder.Services.AddSignalR();
var app = builder.Build();
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, "Views", "Foo", "Scripts")),
RequestPath = "/foo-js"
});
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
});
if (app.Environment.IsDevelopment())
{
app.UseSpa(spa =>
spa.UseProxyToSpaDevelopmentServer("http://localhost:5173/"));
}
app.MapHub<AppHub>("/appHub");
app.Run();