aboutsummaryrefslogtreecommitdiff
path: root/ExamTemplate
diff options
context:
space:
mode:
Diffstat (limited to 'ExamTemplate')
-rw-r--r--ExamTemplate/Web/Controllers/AccountController.cs6
-rw-r--r--ExamTemplate/Web/Controllers/HomeController.cs5
-rw-r--r--ExamTemplate/Web/Startup.cs1
-rw-r--r--ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml10
4 files changed, 19 insertions, 3 deletions
diff --git a/ExamTemplate/Web/Controllers/AccountController.cs b/ExamTemplate/Web/Controllers/AccountController.cs
index f970a2c..a7ad771 100644
--- a/ExamTemplate/Web/Controllers/AccountController.cs
+++ b/ExamTemplate/Web/Controllers/AccountController.cs
@@ -39,7 +39,7 @@ namespace ExamTemplate.Web.Controllers
bool result = await this._userService.RegisterUserAsync(registerUserServiceModel);
if (result)
- return await Login(new LoginUserViewModel {
+ return await this.Login(new LoginUserViewModel {
Username = registerUserServiceModel.Username,
Password = registerUserServiceModel.Password
});
@@ -86,7 +86,7 @@ namespace ExamTemplate.Web.Controllers
UserServiceModel userServiceModel = await this._userService.GetUserByUsernameAsync(username);
if (userServiceModel == default(UserServiceModel))
- return RedirectToAction("Login");
+ return RedirectToAction("ErrorNotFound", "Home");
UserViewModel userViewModel = this._autoMapper.Map<UserViewModel>(userServiceModel);
@@ -99,7 +99,7 @@ namespace ExamTemplate.Web.Controllers
UserServiceModel userServiceModel = await this._userService.GetUserByClaimsAsync(this.HttpContext.User);
if (userServiceModel == default(UserServiceModel))
- return RedirectToAction("Login");
+ return RedirectToAction("ErrorNotFound", "Home");
EditUserViewModel editUserViewModel = this._autoMapper.Map<EditUserViewModel>(userServiceModel);
diff --git a/ExamTemplate/Web/Controllers/HomeController.cs b/ExamTemplate/Web/Controllers/HomeController.cs
index f35cb1e..d9cfc45 100644
--- a/ExamTemplate/Web/Controllers/HomeController.cs
+++ b/ExamTemplate/Web/Controllers/HomeController.cs
@@ -24,5 +24,10 @@ namespace ExamTemplate.Web.Controllers
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
+
+ public IActionResult ErrorNotFound()
+ {
+ return View();
+ }
}
}
diff --git a/ExamTemplate/Web/Startup.cs b/ExamTemplate/Web/Startup.cs
index bfaab91..c294566 100644
--- a/ExamTemplate/Web/Startup.cs
+++ b/ExamTemplate/Web/Startup.cs
@@ -89,6 +89,7 @@ namespace ExamTemplate.Web
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
+ endpoints.MapFallbackToController("ErrorNotFound", "Home");
});
/*
diff --git a/ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml b/ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml
new file mode 100644
index 0000000..39fc5ca
--- /dev/null
+++ b/ExamTemplate/Web/Views/Shared/ErrorNotFound.cshtml
@@ -0,0 +1,10 @@
+@{
+ ViewData["Title"] = "404: Not found!";
+}
+
+<h2>
+ 404: Not found!
+</h2>
+<p>
+ The page you're looking for couldn't be found!
+</p>