Browse Source

Added Error Controller to handle error messages

pull/29/head
Teknikode 7 years ago
parent
commit
9968b89266
  1. 5
      .gitignore
  2. 23
      Teknik/Areas/Error/Controllers/ErrorController.cs
  3. 25
      Teknik/Areas/Error/ErrorAreaRegistration.cs
  4. 13
      Teknik/Areas/Error/ViewModels/ErrorViewModel.cs
  5. 21
      Teknik/Areas/Error/Views/Error/Http404.cshtml
  6. 3
      Teknik/Areas/Error/Views/_ViewStart.cshtml
  7. 36
      Teknik/Areas/Error/Views/web.config
  8. 10
      Teknik/Areas/Profile/Controllers/ProfileController.cs
  9. 40
      Teknik/Areas/Profile/ProfileAreaRegistration.cs
  10. 4
      Teknik/Areas/Profile/Views/Profile/ViewLogin.cshtml
  11. 1
      Teknik/Areas/Profile/Views/Profile/ViewRegistration.cshtml
  12. 12
      Teknik/Areas/Upload/UploadAreaRegistration.cs
  13. 9
      Teknik/Teknik.csproj

5
.gitignore vendored

@ -187,4 +187,7 @@ FakesAssemblies/ @@ -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
Teknik/Areas/Error/Controllers/ErrorController.cs

@ -0,0 +1,23 @@ @@ -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

@ -0,0 +1,25 @@ @@ -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

@ -0,0 +1,13 @@ @@ -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

@ -0,0 +1,21 @@ @@ -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

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

36
Teknik/Areas/Error/Views/web.config

@ -0,0 +1,36 @@ @@ -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
Teknik/Areas/Profile/Controllers/ProfileController.cs

@ -70,6 +70,16 @@ namespace Teknik.Areas.Profile.Controllers @@ -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)

40
Teknik/Areas/Profile/ProfileAreaRegistration.cs

@ -21,6 +21,20 @@ namespace Teknik.Areas.Profile @@ -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 @@ -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(

4
Teknik/Areas/Profile/Views/Profile/ViewLogin.cshtml

@ -4,10 +4,10 @@ @@ -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
Teknik/Areas/Profile/Views/Profile/ViewRegistration.cshtml

@ -0,0 +1 @@ @@ -0,0 +1 @@


12
Teknik/Areas/Upload/UploadAreaRegistration.cs

@ -53,21 +53,21 @@ namespace Teknik.Areas.Upload @@ -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 @@ -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
Teknik/Teknik.csproj

@ -152,6 +152,9 @@ @@ -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 @@ @@ -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 @@ @@ -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