1
0
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:
Uncled1023 2015-12-22 12:05:50 -08:00
parent a02e4e15e5
commit 9968b89266
13 changed files with 188 additions and 16 deletions

3
.gitignore vendored
View File

@ -188,3 +188,6 @@ FakesAssemblies/
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/Teknik/ConnectionStrings.config
/Teknik/App_Data/Config.json
/.vs/config/applicationhost.config

View 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();
}
}
}

View 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 }
);
}
}
}

View 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
{
}
}

View 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>

View File

@ -0,0 +1,3 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}

View 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>

View File

@ -70,6 +70,16 @@ namespace Teknik.Areas.Profile.Controllers
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]
[AllowAnonymous]
public ActionResult Register(RegisterViewModel model)

View File

@ -21,6 +21,20 @@ namespace Teknik.Areas.Profile
new { controller = "Profile", action = "Login" }, // Parameter defaults
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(
"Profile_dev", // Route name
"dev",
@ -35,13 +49,6 @@ namespace Teknik.Areas.Profile
new { controller = "Profile", action = "Index" }, // 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(
"Profile_default_login", // Route name
"profile",
@ -49,6 +56,27 @@ namespace Teknik.Areas.Profile
new { controller = "Profile", action = "Login" }, // Parameter defaults
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(
"Profile_default_unique", // Route name
"profile",

View File

@ -4,10 +4,10 @@
<div class="row">
<div class="col-md-12">
<div class="error-template text-center">
<h1>Stay Away!</h1>
<h1>No Access</h1>
<h2>403 Access Denied</h2>
<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>
<br />
<div class="error-actions">

View File

@ -0,0 +1 @@


View File

@ -53,21 +53,21 @@ namespace Teknik.Areas.Upload
context.MapSubdomainRoute(
"Upload_default_short_download",
"u",
"Upload/{url}",
"{url}",
new { controller = "Upload", action = "Download", url = "" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_short_delete",
"u",
"Upload/{url}/{deleteKey}",
"{url}/{deleteKey}",
new { controller = "Upload", action = "Download", url = string.Empty, deleteKey = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_short_action",
"u",
"Upload/Action/{controller}/{action}",
"Action/{controller}/{action}",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
@ -81,21 +81,21 @@ namespace Teknik.Areas.Upload
context.MapSubdomainRoute(
"Upload_default_long_download",
"upload",
"Upload/{url}",
"{url}",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_long_delete",
"upload",
"Upload/{url}/{deleteKey}",
"{url}/{deleteKey}",
new { controller = "Upload", action = "Index", url = string.Empty, deleteKey = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_long_action",
"upload",
"Upload/Action/{controller}/{action}",
"Action/{controller}/{action}",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);

View File

@ -152,6 +152,9 @@
<Compile Include="Areas\Contact\Models\Contact.cs" />
<Compile Include="Areas\Contact\ViewModels\ContactViewModel.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\HomeAreaRegistration.cs" />
<Compile Include="Areas\Home\ViewModels\HomeViewModel.cs" />
@ -265,6 +268,10 @@
<Content Include="Areas\Upload\Views\web.config" />
<Content Include="Areas\Upload\Views\Upload\Index.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="Scripts\jquery-2.1.4.intellisense.js" />
<Content Include="Scripts\bootbox\bootbox.min.js" />
@ -325,6 +332,8 @@
<Folder Include="Areas\Contact\Views\Shared\" />
<Folder Include="Areas\Dev\Models\" />
<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\Views\Shared\" />
<Folder Include="Areas\Privacy\Models\" />