33 lines
884 B
C#
33 lines
884 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace WebApplication1.Controllers;
|
|
|
|
[Route("")]
|
|
public class DefaultController(ViteHelper vite) : SiteControllerBase(vite)
|
|
{
|
|
[HttpGet]
|
|
public async Task<IActionResult> Get()
|
|
{
|
|
if (!Request.Path.HasValue || !Request.Path.Value.EndsWith('/'))
|
|
{
|
|
return RedirectPermanent($"{Request.PathBase}/{Request.QueryString}");
|
|
}
|
|
|
|
var html = await viteHelper.RenderAsync(
|
|
Request.PathBase,
|
|
"main.html",
|
|
"src/main.ts",
|
|
new() { ["Title"] = "Home Page" });
|
|
|
|
return Content(html, "text/html; charset=utf-8");
|
|
}
|
|
|
|
[Route("test/error")]
|
|
[HttpGet]
|
|
[ResponseCache(CacheProfileName = "NoCache")]
|
|
public IActionResult GetTest()
|
|
{
|
|
throw new PermissionException(400, errorMessage: "This is a test permission exception.");
|
|
}
|
|
}
|