-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (39 loc) · 1.26 KB
/
Copy pathProgram.cs
File metadata and controls
52 lines (39 loc) · 1.26 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
50
51
52
using AspNetCoreHero.ToastNotification;
using ToastNotification.Docs;
var builder = WebApplication.CreateBuilder(args);
// This docs app shows every workload: MVC controllers, Razor Pages and Minimal APIs.
builder.Services.AddControllersWithViews();
builder.Services.AddRazorPages();
// 1. Register the toast library.
// This app registers BOTH so the page can compare them. Your app only needs one.
builder.Services.AddNotyf(config =>
{
config.DurationInSeconds = 5;
config.IsDismissable = true;
config.Position = NotyfPosition.BottomRight;
});
builder.Services.AddToastify(config =>
{
config.DurationInSeconds = 5;
config.Gravity = Gravity.Bottom;
config.Position = Position.Left;
});
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
// 2. Show toasts raised during fetch / AJAX / htmx requests.
// One call covers both libraries (UseToastify() is the same middleware).
app.UseNotyf();
app.UseAuthorization();
app.MapDefaultControllerRoute();
app.MapRazorPages();
// Minimal API endpoints behind the playground and the AJAX demos.
app.MapDemoEndpoints();
app.Run();
public partial class Program;