diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-06-01 21:13:43 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-06-01 21:13:43 +0200 |
| commit | 9383a2fb09ffb60cfe63683106945bd688affa59 (patch) | |
| tree | 65b3f4b48841583e355887db5de5a16e7005fc87 /src/Pages/Errors | |
| download | vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.tar.xz vinjesvingenhandel.no-9383a2fb09ffb60cfe63683106945bd688affa59.zip | |
feat: Initial commit after clean slate
Diffstat (limited to 'src/Pages/Errors')
| -rw-r--r-- | src/Pages/Errors/Index.cshtml | 33 | ||||
| -rw-r--r-- | src/Pages/Errors/Index.cshtml.cs | 19 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/Pages/Errors/Index.cshtml b/src/Pages/Errors/Index.cshtml new file mode 100644 index 0000000..5db7b59 --- /dev/null +++ b/src/Pages/Errors/Index.cshtml @@ -0,0 +1,33 @@ +@page "{code}" +@using System.Net +@model VSH.Pages.Errors.Index +@{ + ViewData["Title"] = Model.ErrorStatusCode switch { + HttpStatusCode.NotFound => "Fant ikkje sida", + var _ => "Uventa feil" + }; +} +<section class="container py-3 py-lg-5"> + @switch (Model.ErrorStatusCode) { + case HttpStatusCode.NotFound: + <div class="text-component text-center margin-bottom-lg"> + <h1>Fant ikkje siden</h1> + <p>Beklagar, sida du prøvar å nå finnes ikkje.</p> + <p><a href="/">Gå til forsida</a> eller <a href="/kontakt">kontakt oss</a>.</p> + </div> + break; + case HttpStatusCode.InternalServerError: + <div class="text-component text-center margin-bottom-lg"> + <h1>Her gjekk noko gale</h1> + <p>Vi jobbar med å løysa problemet, ver vennleg og prøv igjen seinare.</p> + </div> + break; + default: + <div class="text-component text-center margin-bottom-lg"> + <h1>Heisann, her gjekk ikkje alt etter planen</h1> + <p>Ver vennleg og prøv igjen snart.</p> + <p><a href="/">Gå til forsida</a> eller <a href="/kontakt">kontakt oss</a>.</p> + </div> + break; + } +</section> diff --git a/src/Pages/Errors/Index.cshtml.cs b/src/Pages/Errors/Index.cshtml.cs new file mode 100644 index 0000000..05e405d --- /dev/null +++ b/src/Pages/Errors/Index.cshtml.cs @@ -0,0 +1,19 @@ +using System; +using System.Net; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace VSH.Pages.Errors; + +public class Index : PageModel +{ + public HttpStatusCode ErrorStatusCode { get; set; } + + public void OnGet() { + try { + if (int.TryParse(RouteData.Values["code"]?.ToString(), out var status)) + ErrorStatusCode = (HttpStatusCode)status; + } catch (Exception e) { + Console.WriteLine(e); + } + } +}
\ No newline at end of file |
