From ca965d536278a4970ede0b88a92c6f218bfc5915 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 12 May 2021 10:16:49 +0300 Subject: Implemented a 404 not found page --- ExamTemplate/Web/Controllers/AccountController.cs | 6 +++--- ExamTemplate/Web/Controllers/HomeController.cs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'ExamTemplate/Web/Controllers') 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(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(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(); + } } } -- cgit v1.2.3