Skip to content

Commit 9fe34a5

Browse files
committed
create errorcontroller
1 parent 2f95882 commit 9fe34a5

20 files changed

Lines changed: 5636 additions & 19 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace HRManagementSystem.UI.Controllers
4+
{
5+
public class ErrorController : Controller
6+
{
7+
public IActionResult NotFoundPage()
8+
{
9+
return View();
10+
}
11+
12+
public IActionResult AccessDeniedPage()
13+
{
14+
return View();
15+
}
16+
}
17+
}

HRManagementSystem.UI/Program.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
opt.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
2020
opt.ExpireTimeSpan = TimeSpan.FromDays(7);
2121
opt.LoginPath = new PathString("/Account/SignIn");
22-
opt.LoginPath = new PathString("/Account/LogOut");
23-
opt.AccessDeniedPath = new PathString("/Account/AccessDenied");
22+
opt.LogoutPath = new PathString("/Account/LogOut");
23+
opt.AccessDeniedPath = new PathString("/Error/AccessDeniedPage");
2424
});
2525

2626

@@ -71,5 +71,4 @@ void Configure(WebApplication app, IWebHostEnvironment env)
7171
app.UseAuthorization();
7272

7373
app.MapDefaultControllerRoute();
74-
}
75-
74+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@{
2+
ViewData["Title"] = "AccessDeniedPage";
3+
Layout = "~/Views/Shared/_Layout.cshtml";
4+
}
5+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Merriweather:400,400i" />
6+
<link rel="stylesheet" href="~/403Forbidden//dist/style.css">
7+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
8+
<body>
9+
<div class="wrapper">
10+
<div class="box">
11+
<h1>403</h1>
12+
<p>Sorry, it's not allowed to go beyond this point!</p>
13+
<p><a asp-action="Index" asp-controller="Home">Please, go back this way.</a></p>
14+
</div>
15+
</div>
16+
</body>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@{
2+
ViewData["Title"] = "NotFoundPage";
3+
Layout = "~/Views/Shared/_Layout.cshtml";
4+
}
5+
6+
@section css {
7+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
8+
<style>
9+
.error-container {
10+
text-align: center;
11+
}
12+
13+
.error-code {
14+
font-size: 96px;
15+
font-weight: bold;
16+
color: #343a40;
17+
}
18+
19+
.error-message {
20+
font-size: 24px;
21+
margin-bottom: 30px;
22+
color: #6c757d;
23+
}
24+
25+
.back-button {
26+
font-size: 18px;
27+
padding: 10px 30px;
28+
border-radius: 25px;
29+
}
30+
</style>
31+
}
32+
33+
<body>
34+
<div class="error-container">
35+
<div class="error-code">404</div>
36+
<div class="error-message">Oops! The page you are looking for cannot be found.</div>
37+
<a asp-action="Index" asp-controller="Home" class="btn btn-primary back-button">Go Back to Home</a>
38+
</div>
39+
40+
@section script {
41+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
42+
}
43+
</body>

HRManagementSystem.UI/Views/Home/Index.cshtml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
Layout = "~/Views/Shared/_Layout.cshtml";
55
}
66

7-
<style>
8-
.card {
9-
display: flex;
10-
flex-direction: column;
11-
height: 100%;
12-
}
7+
@section css {
8+
<style>
9+
.card {
10+
display: flex;
11+
flex-direction: column;
12+
height: 100%;
13+
}
1314
14-
.card-body {
15-
flex: 1;
16-
}
15+
.card-body {
16+
flex: 1;
17+
}
1718
18-
.card-img-top {
19-
height: 15rem;
20-
object-fit: cover;
21-
}
22-
</style>
19+
.card-img-top {
20+
height: 15rem;
21+
object-fit: cover;
22+
}
23+
</style>
24+
}
2325

2426
<h2 class="px-4">Our Services</h2>
2527

@@ -38,4 +40,4 @@
3840
</div>
3941
}
4042
</div>
41-
</div>
43+
</div>

0 commit comments

Comments
 (0)