INitial work
This commit is contained in:
26
Pages/Error.cshtml
Normal file
26
Pages/Error.cshtml
Normal file
@@ -0,0 +1,26 @@
|
||||
@page
|
||||
@model ErrorModel
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (Model.ShowRequestId)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||
</p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||
It can result in displaying sensitive information from exceptions to end users.
|
||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||
and restarting the app.
|
||||
</p>
|
||||
27
Pages/Error.cshtml.cs
Normal file
27
Pages/Error.cshtml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace ForgetMeNot.Pages;
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
[IgnoreAntiforgeryToken]
|
||||
public class ErrorModel : PageModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
private readonly ILogger<ErrorModel> _logger;
|
||||
|
||||
public ErrorModel(ILogger<ErrorModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
6
Pages/Index.cshtml
Normal file
6
Pages/Index.cshtml
Normal file
@@ -0,0 +1,6 @@
|
||||
@page
|
||||
@model ForgetMeNot.Web.IndexModel
|
||||
@{
|
||||
}
|
||||
|
||||
<p>Hello there!</p>
|
||||
12
Pages/Index.cshtml.cs
Normal file
12
Pages/Index.cshtml.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace ForgetMeNot.Web
|
||||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
6
Pages/Sample.cshtml
Normal file
6
Pages/Sample.cshtml
Normal file
@@ -0,0 +1,6 @@
|
||||
@page
|
||||
@model ForgetMeNot.Web.SampleModel
|
||||
@{
|
||||
}
|
||||
|
||||
<strong>The button <em>was</em> here!</strong>
|
||||
12
Pages/Sample.cshtml.cs
Normal file
12
Pages/Sample.cshtml.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace ForgetMeNot.Web
|
||||
{
|
||||
public class SampleModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Pages/Shared/_Layout.cshtml
Normal file
40
Pages/Shared/_Layout.cshtml
Normal file
@@ -0,0 +1,40 @@
|
||||
@{
|
||||
var isHtmxRequest = ViewContext.HttpContext.Request.Headers["hx-request"].Any(v => v == "true");
|
||||
var isHtmxHistoryRestoreRequest = ViewContext.HttpContext.Request.Headers["hx-history-restore-request"].Any(v => v == "true");
|
||||
}
|
||||
|
||||
@if (!isHtmxRequest || isHtmxHistoryRestoreRequest)
|
||||
{
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>forget me not</title>
|
||||
|
||||
<link rel="stylesheet" href="~/css/styles.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/ForgetMeNot.styles.css" asp-append-version="true" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header></header>
|
||||
<main>
|
||||
<h1>The Site is here!</h1>
|
||||
@RenderBody()
|
||||
</main>
|
||||
<footer>
|
||||
<span>header: @ViewContext.HttpContext.Request.Headers["HX-Request"]</span>
|
||||
<button hx-get="/sample" hx-swap="outerHTML">Replace me</button>
|
||||
</footer>
|
||||
|
||||
<script src="https://unpkg.com/htmx.org@1.8.0"></script>
|
||||
<script src="https://unpkg.com/hyperscript.org@0.9.7"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>@RenderBody()</text>
|
||||
}
|
||||
0
Pages/Shared/_Layout.cshtml.css
Normal file
0
Pages/Shared/_Layout.cshtml.css
Normal file
3
Pages/_ViewImports.cshtml
Normal file
3
Pages/_ViewImports.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
@using ForgetMeNot
|
||||
@namespace ForgetMeNot.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
3
Pages/_ViewStart.cshtml
Normal file
3
Pages/_ViewStart.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
Reference in New Issue
Block a user