mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added Error Controller to handle error messages
This commit is contained in:
parent
a02e4e15e5
commit
9968b89266
3
.gitignore
vendored
3
.gitignore
vendored
@ -188,3 +188,6 @@ FakesAssemblies/
|
|||||||
GeneratedArtifacts/
|
GeneratedArtifacts/
|
||||||
_Pvt_Extensions/
|
_Pvt_Extensions/
|
||||||
ModelManifest.xml
|
ModelManifest.xml
|
||||||
|
/Teknik/ConnectionStrings.config
|
||||||
|
/Teknik/App_Data/Config.json
|
||||||
|
/.vs/config/applicationhost.config
|
||||||
|
23
Teknik/Areas/Error/Controllers/ErrorController.cs
Normal file
23
Teknik/Areas/Error/Controllers/ErrorController.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Teknik.Controllers;
|
||||||
|
|
||||||
|
namespace Teknik.Areas.Error.Controllers
|
||||||
|
{
|
||||||
|
public class ErrorController : DefaultController
|
||||||
|
{
|
||||||
|
// GET: Error/Error
|
||||||
|
public ActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Http404()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
Teknik/Areas/Error/ErrorAreaRegistration.cs
Normal file
25
Teknik/Areas/Error/ErrorAreaRegistration.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
|
namespace Teknik.Areas.Error
|
||||||
|
{
|
||||||
|
public class ErrorAreaRegistration : AreaRegistration
|
||||||
|
{
|
||||||
|
public override string AreaName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RegisterArea(AreaRegistrationContext context)
|
||||||
|
{
|
||||||
|
context.MapRoute(
|
||||||
|
"404-PageNotFound",
|
||||||
|
"{*url}",
|
||||||
|
new { controller = "ErrorController", action = "Http404" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.ErrorController).Namespace }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
Teknik/Areas/Error/ViewModels/ErrorViewModel.cs
Normal file
13
Teknik/Areas/Error/ViewModels/ErrorViewModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Teknik.ViewModels;
|
||||||
|
|
||||||
|
namespace Teknik.Areas.Error.ViewModels
|
||||||
|
{
|
||||||
|
public class ErrorViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
21
Teknik/Areas/Error/Views/Error/Http404.cshtml
Normal file
21
Teknik/Areas/Error/Views/Error/Http404.cshtml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
@model Teknik.Areas.Error.ViewModels.ErrorViewModel
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="error-template text-center">
|
||||||
|
<h1>Oops!</h1>
|
||||||
|
<h2>404 Not Found</h2>
|
||||||
|
<div class="error-details">
|
||||||
|
Sorry, an error has occured, Requested page not found!
|
||||||
|
</div>
|
||||||
|
<div class="error-actions">
|
||||||
|
<a href="@Url.SubAction("www", "Index", "Home", new { area = "Home"})" class="btn btn-primary btn-lg"><span class="glyphicon glyphicon-home"></span>
|
||||||
|
Take Me Home
|
||||||
|
</a><a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact"})" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-envelope"></span> Contact Support </a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
3
Teknik/Areas/Error/Views/_ViewStart.cshtml
Normal file
3
Teknik/Areas/Error/Views/_ViewStart.cshtml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
36
Teknik/Areas/Error/Views/web.config
Normal file
36
Teknik/Areas/Error/Views/web.config
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||||
|
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||||
|
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
|
|
||||||
|
<system.web.webPages.razor>
|
||||||
|
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||||
|
<pages pageBaseType="System.Web.Mvc.WebViewPage">
|
||||||
|
<namespaces>
|
||||||
|
<add namespace="System.Web.Mvc" />
|
||||||
|
<add namespace="System.Web.Mvc.Ajax" />
|
||||||
|
<add namespace="System.Web.Mvc.Html" />
|
||||||
|
<add namespace="System.Web.Routing" />
|
||||||
|
<add namespace="System.Web.Optimization" />
|
||||||
|
<add namespace="Teknik" />
|
||||||
|
|
||||||
|
</namespaces>
|
||||||
|
</pages>
|
||||||
|
</system.web.webPages.razor>
|
||||||
|
|
||||||
|
<appSettings>
|
||||||
|
<add key="webpages:Enabled" value="false" />
|
||||||
|
</appSettings>
|
||||||
|
|
||||||
|
<system.webServer>
|
||||||
|
<handlers>
|
||||||
|
<remove name="BlockViewHandler"/>
|
||||||
|
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
|
||||||
|
</handlers>
|
||||||
|
</system.webServer>
|
||||||
|
</configuration>
|
@ -70,6 +70,16 @@ namespace Teknik.Areas.Profile.Controllers
|
|||||||
return RedirectToAction("Index", "Home", new { Area = "Home" });
|
return RedirectToAction("Index", "Home", new { Area = "Home" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
// GET: Profile
|
||||||
|
public ActionResult Register()
|
||||||
|
{
|
||||||
|
RegisterViewModel model = new RegisterViewModel();
|
||||||
|
|
||||||
|
return View("/Areas/Profile/Views/Profile/ViewRegistration.cshtml", model);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public ActionResult Register(RegisterViewModel model)
|
public ActionResult Register(RegisterViewModel model)
|
||||||
|
@ -21,6 +21,20 @@ namespace Teknik.Areas.Profile
|
|||||||
new { controller = "Profile", action = "Login" }, // Parameter defaults
|
new { controller = "Profile", action = "Login" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ProfileController).Namespace }
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
);
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Profile_dev_logout", // Route name
|
||||||
|
"dev",
|
||||||
|
"Profile/Logout", // URL with parameters
|
||||||
|
new { controller = "Profile", action = "Logout" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Profile_dev_Register", // Route name
|
||||||
|
"dev",
|
||||||
|
"Profile/Login", // URL with parameters
|
||||||
|
new { controller = "Profile", action = "Register" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Profile_dev", // Route name
|
"Profile_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
@ -35,13 +49,6 @@ namespace Teknik.Areas.Profile
|
|||||||
new { controller = "Profile", action = "Index" }, // Parameter defaults
|
new { controller = "Profile", action = "Index" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ProfileController).Namespace }
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
|
||||||
"Profile_default", // Route name
|
|
||||||
"profile",
|
|
||||||
"{username}", // URL with parameters
|
|
||||||
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
|
|
||||||
new[] { typeof(Controllers.ProfileController).Namespace }
|
|
||||||
);
|
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Profile_default_login", // Route name
|
"Profile_default_login", // Route name
|
||||||
"profile",
|
"profile",
|
||||||
@ -49,6 +56,27 @@ namespace Teknik.Areas.Profile
|
|||||||
new { controller = "Profile", action = "Login" }, // Parameter defaults
|
new { controller = "Profile", action = "Login" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ProfileController).Namespace }
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
);
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Profile_default_logout", // Route name
|
||||||
|
"profile",
|
||||||
|
"Logout", // URL with parameters
|
||||||
|
new { controller = "Profile", action = "Logout" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Profile_default_register", // Route name
|
||||||
|
"profile",
|
||||||
|
"Register", // URL with parameters
|
||||||
|
new { controller = "Profile", action = "Register" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Profile_default", // Route name
|
||||||
|
"profile",
|
||||||
|
"{username}", // URL with parameters
|
||||||
|
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Profile_default_unique", // Route name
|
"Profile_default_unique", // Route name
|
||||||
"profile",
|
"profile",
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="error-template text-center">
|
<div class="error-template text-center">
|
||||||
<h1>Stay Away!</h1>
|
<h1>No Access</h1>
|
||||||
<h2>403 Access Denied</h2>
|
<h2>403 Access Denied</h2>
|
||||||
<div class="error-details">
|
<div class="error-details">
|
||||||
You aren't allowed to see this! If you think you are, then login below.
|
You aren't allowed to see this! If you think you are, then please login below.
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<div class="error-actions">
|
<div class="error-actions">
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -53,21 +53,21 @@ namespace Teknik.Areas.Upload
|
|||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Upload_default_short_download",
|
"Upload_default_short_download",
|
||||||
"u",
|
"u",
|
||||||
"Upload/{url}",
|
"{url}",
|
||||||
new { controller = "Upload", action = "Download", url = "" },
|
new { controller = "Upload", action = "Download", url = "" },
|
||||||
new[] { typeof(Controllers.UploadController).Namespace }
|
new[] { typeof(Controllers.UploadController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Upload_default_short_delete",
|
"Upload_default_short_delete",
|
||||||
"u",
|
"u",
|
||||||
"Upload/{url}/{deleteKey}",
|
"{url}/{deleteKey}",
|
||||||
new { controller = "Upload", action = "Download", url = string.Empty, deleteKey = string.Empty },
|
new { controller = "Upload", action = "Download", url = string.Empty, deleteKey = string.Empty },
|
||||||
new[] { typeof(Controllers.UploadController).Namespace }
|
new[] { typeof(Controllers.UploadController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Upload_default_short_action",
|
"Upload_default_short_action",
|
||||||
"u",
|
"u",
|
||||||
"Upload/Action/{controller}/{action}",
|
"Action/{controller}/{action}",
|
||||||
new { controller = "Upload", action = "Index" },
|
new { controller = "Upload", action = "Index" },
|
||||||
new[] { typeof(Controllers.UploadController).Namespace }
|
new[] { typeof(Controllers.UploadController).Namespace }
|
||||||
);
|
);
|
||||||
@ -81,21 +81,21 @@ namespace Teknik.Areas.Upload
|
|||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Upload_default_long_download",
|
"Upload_default_long_download",
|
||||||
"upload",
|
"upload",
|
||||||
"Upload/{url}",
|
"{url}",
|
||||||
new { controller = "Upload", action = "Index" },
|
new { controller = "Upload", action = "Index" },
|
||||||
new[] { typeof(Controllers.UploadController).Namespace }
|
new[] { typeof(Controllers.UploadController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Upload_default_long_delete",
|
"Upload_default_long_delete",
|
||||||
"upload",
|
"upload",
|
||||||
"Upload/{url}/{deleteKey}",
|
"{url}/{deleteKey}",
|
||||||
new { controller = "Upload", action = "Index", url = string.Empty, deleteKey = string.Empty },
|
new { controller = "Upload", action = "Index", url = string.Empty, deleteKey = string.Empty },
|
||||||
new[] { typeof(Controllers.UploadController).Namespace }
|
new[] { typeof(Controllers.UploadController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Upload_default_long_action",
|
"Upload_default_long_action",
|
||||||
"upload",
|
"upload",
|
||||||
"Upload/Action/{controller}/{action}",
|
"Action/{controller}/{action}",
|
||||||
new { controller = "Upload", action = "Index" },
|
new { controller = "Upload", action = "Index" },
|
||||||
new[] { typeof(Controllers.UploadController).Namespace }
|
new[] { typeof(Controllers.UploadController).Namespace }
|
||||||
);
|
);
|
||||||
|
@ -152,6 +152,9 @@
|
|||||||
<Compile Include="Areas\Contact\Models\Contact.cs" />
|
<Compile Include="Areas\Contact\Models\Contact.cs" />
|
||||||
<Compile Include="Areas\Contact\ViewModels\ContactViewModel.cs" />
|
<Compile Include="Areas\Contact\ViewModels\ContactViewModel.cs" />
|
||||||
<Compile Include="Areas\Dev\DevAreaRegistration.cs" />
|
<Compile Include="Areas\Dev\DevAreaRegistration.cs" />
|
||||||
|
<Compile Include="Areas\Error\Controllers\ErrorController.cs" />
|
||||||
|
<Compile Include="Areas\Error\ErrorAreaRegistration.cs" />
|
||||||
|
<Compile Include="Areas\Error\ViewModels\ErrorViewModel.cs" />
|
||||||
<Compile Include="Areas\Home\Controllers\HomeController.cs" />
|
<Compile Include="Areas\Home\Controllers\HomeController.cs" />
|
||||||
<Compile Include="Areas\Home\HomeAreaRegistration.cs" />
|
<Compile Include="Areas\Home\HomeAreaRegistration.cs" />
|
||||||
<Compile Include="Areas\Home\ViewModels\HomeViewModel.cs" />
|
<Compile Include="Areas\Home\ViewModels\HomeViewModel.cs" />
|
||||||
@ -265,6 +268,10 @@
|
|||||||
<Content Include="Areas\Upload\Views\web.config" />
|
<Content Include="Areas\Upload\Views\web.config" />
|
||||||
<Content Include="Areas\Upload\Views\Upload\Index.cshtml" />
|
<Content Include="Areas\Upload\Views\Upload\Index.cshtml" />
|
||||||
<Content Include="Areas\Upload\Views\_ViewStart.cshtml" />
|
<Content Include="Areas\Upload\Views\_ViewStart.cshtml" />
|
||||||
|
<Content Include="Areas\Profile\Views\Profile\ViewRegistration.cshtml" />
|
||||||
|
<Content Include="Areas\Error\Views\web.config" />
|
||||||
|
<Content Include="Areas\Error\Views\Error\Http404.cshtml" />
|
||||||
|
<Content Include="Areas\Error\Views\_ViewStart.cshtml" />
|
||||||
<None Include="Properties\PublishProfiles\Teknik Dev.pubxml" />
|
<None Include="Properties\PublishProfiles\Teknik Dev.pubxml" />
|
||||||
<None Include="Scripts\jquery-2.1.4.intellisense.js" />
|
<None Include="Scripts\jquery-2.1.4.intellisense.js" />
|
||||||
<Content Include="Scripts\bootbox\bootbox.min.js" />
|
<Content Include="Scripts\bootbox\bootbox.min.js" />
|
||||||
@ -325,6 +332,8 @@
|
|||||||
<Folder Include="Areas\Contact\Views\Shared\" />
|
<Folder Include="Areas\Contact\Views\Shared\" />
|
||||||
<Folder Include="Areas\Dev\Models\" />
|
<Folder Include="Areas\Dev\Models\" />
|
||||||
<Folder Include="Areas\Dev\Views\Shared\" />
|
<Folder Include="Areas\Dev\Views\Shared\" />
|
||||||
|
<Folder Include="Areas\Error\Models\" />
|
||||||
|
<Folder Include="Areas\Error\Views\Shared\" />
|
||||||
<Folder Include="Areas\Home\Models\" />
|
<Folder Include="Areas\Home\Models\" />
|
||||||
<Folder Include="Areas\Home\Views\Shared\" />
|
<Folder Include="Areas\Home\Views\Shared\" />
|
||||||
<Folder Include="Areas\Privacy\Models\" />
|
<Folder Include="Areas\Privacy\Models\" />
|
||||||
|
Loading…
Reference in New Issue
Block a user