Browse Source

Added Error Controller to handle error messages

tags/2.0.3
Teknikode 4 years ago
parent
commit
9968b89266

+ 4
- 1
.gitignore View File

@@ -187,4 +187,7 @@ FakesAssemblies/
# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
ModelManifest.xml
/Teknik/ConnectionStrings.config
/Teknik/App_Data/Config.json
/.vs/config/applicationhost.config

+ 23
- 0
Teknik/Areas/Error/Controllers/ErrorController.cs 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();
}
}
}

+ 25
- 0
Teknik/Areas/Error/ErrorAreaRegistration.cs 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 }
);
}
}
}

+ 13
- 0
Teknik/Areas/Error/ViewModels/ErrorViewModel.cs 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
{
}
}

+ 21
- 0
Teknik/Areas/Error/Views/Error/Http404.cshtml 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>


+ 3
- 0
Teknik/Areas/Error/Views/_ViewStart.cshtml View File

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

+ 36
- 0
Teknik/Areas/Error/Views/web.config 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>

+ 10
- 0
Teknik/Areas/Profile/Controllers/ProfileController.cs 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)

+ 34
- 6
Teknik/Areas/Profile/ProfileAreaRegistration.cs 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",
@@ -36,17 +50,31 @@ namespace Teknik.Areas.Profile
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default", // Route name
"Profile_default_login", // Route name
"profile",
"{username}", // URL with parameters
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
"Login", // URL with parameters
new { controller = "Profile", action = "Login" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default_login", // Route name
"Profile_default_logout", // Route name
"profile",
"Login", // URL with parameters
new { controller = "Profile", action = "Login" }, // Parameter defaults
"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(

+ 2
- 2
Teknik/Areas/Profile/Views/Profile/ViewLogin.cshtml 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">

+ 1
- 0
Teknik/Areas/Profile/Views/Profile/ViewRegistration.cshtml View File

@@ -0,0 +1 @@


+ 6
- 6
Teknik/Areas/Upload/UploadAreaRegistration.cs 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 }
);

+ 9
- 0
Teknik/Teknik.csproj 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\" />

Loading…
Cancel
Save