Skip to content

Commit

Permalink
Setup with pure config and error files
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenbock committed Feb 4, 2017
1 parent 2a7a451 commit fe02ff7
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 53 deletions.
13 changes: 13 additions & 0 deletions AchmeErrorSite/400.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%@ Page validateRequest="false" %>
<% Response.StatusCode = 400;%>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>400 Server Error</title>
</head>
<body>
<h1>AST.NET 400 Server Error</h1>
</body>
</html>
12 changes: 12 additions & 0 deletions AchmeErrorSite/404.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% Response.StatusCode = 404; %>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>404 Server Error</title>
</head>
<body>
<h1>AST.NET 404 Server Error</h1>
</body>
</html>
10 changes: 10 additions & 0 deletions AchmeErrorSite/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<meta charset="utf-8" />
</head>
<body>
<p>IIS 404 Error ocurred. Nice message here.</p>
</body>
</html>
13 changes: 13 additions & 0 deletions AchmeErrorSite/500.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% Response.StatusCode = 500;%>


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>500 Server Error</title>
</head>
<body>
<h1>AST.NET 500 Server Error</h1>
</body>
</html>
2 changes: 1 addition & 1 deletion AchmeErrorSite/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<meta charset="utf-8" />
</head>
<body>
<p>Error ocurred. Nice message here.</p>
<p>IIS 500 Error ocurred. Nice message here.</p>
</body>
</html>
6 changes: 5 additions & 1 deletion AchmeErrorSite/AchmeErrorSite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="404.html" />
<Content Include="404.aspx" />
<Content Include="400.aspx" />
<Content Include="500.aspx" />
<Content Include="500.html" />
<Content Include="packages.config" />
<Content Include="config\imageprocessor\security.config" />
Expand Down Expand Up @@ -428,6 +432,7 @@
<Content Include="Views\CompiledError.cshtml" />
<Content Include="Views\Home.cshtml" />
<Content Include="Views\RazorError.cshtml" />
<Content Include="Views\notfound.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand Down Expand Up @@ -465,7 +470,6 @@
<ItemGroup>
<Compile Include="AchmeClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SiteApplication.cs" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
Expand Down
2 changes: 1 addition & 1 deletion AchmeErrorSite/AchmeErrorSite.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UseIISExpress>true</UseIISExpress>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
Expand Down
2 changes: 1 addition & 1 deletion AchmeErrorSite/App_Data/Models/all.dll.path
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\75441ed1\d5440aaf\App_Web_all.generated.cs.8f9494c4.9mgasjtp.dll
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\75441ed1\d5440aaf\App_Web_all.generated.cs.8f9494c4.ck2draoq.dll
28 changes: 27 additions & 1 deletion AchmeErrorSite/App_Data/Models/all.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Umbraco.ModelsBuilder;
using Umbraco.ModelsBuilder.Umbraco;
[assembly: PureLiveAssembly]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "e5880c86ae4e4cee")]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "903c58d4a6e8a2bf")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.1")]


Expand Down Expand Up @@ -118,6 +118,32 @@ public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func
}
}

/// <summary>notfound</summary>
[PublishedContentModel("notfound")]
public partial class Notfound : PublishedContentModel
{
#pragma warning disable 0109 // new is redundant
public new const string ModelTypeAlias = "notfound";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
#pragma warning restore 0109

public Notfound(IPublishedContent content)
: base(content)
{ }

#pragma warning disable 0109 // new is redundant
public new static PublishedContentType GetModelContentType()
{
return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
}
#pragma warning restore 0109

public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<Notfound, TValue>> selector)
{
return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
}
}

/// <summary>Folder</summary>
[PublishedContentModel("Folder")]
public partial class Folder : PublishedContentModel
Expand Down
30 changes: 28 additions & 2 deletions AchmeErrorSite/App_Data/Models/models.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
using Umbraco.ModelsBuilder.Umbraco;

[assembly: PureLiveAssembly]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "e5880c86ae4e4cee")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.1")]
[assembly:ModelsBuilderAssembly(PureLive = true, SourceHash = "903c58d4a6e8a2bf")]
[assembly:System.Reflection.AssemblyVersion("0.0.0.2")]

namespace Umbraco.Web.PublishedContentModels
{
Expand Down Expand Up @@ -102,6 +102,32 @@ public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func
}
}

/// <summary>notfound</summary>
[PublishedContentModel("notfound")]
public partial class Notfound : PublishedContentModel
{
#pragma warning disable 0109 // new is redundant
public new const string ModelTypeAlias = "notfound";
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
#pragma warning restore 0109

public Notfound(IPublishedContent content)
: base(content)
{ }

#pragma warning disable 0109 // new is redundant
public new static PublishedContentType GetModelContentType()
{
return PublishedContentType.Get(ModelItemType, ModelTypeAlias);
}
#pragma warning restore 0109

public static PublishedPropertyType GetModelPropertyType<TValue>(Expression<Func<Notfound, TValue>> selector)
{
return PublishedContentModelUtility.GetModelPropertyType(GetModelContentType(), selector);
}
}

/// <summary>Folder</summary>
[PublishedContentModel("Folder")]
public partial class Folder : PublishedContentModel
Expand Down
2 changes: 1 addition & 1 deletion AchmeErrorSite/App_Data/Models/models.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e5880c86ae4e4cee
903c58d4a6e8a2bf
Binary file modified AchmeErrorSite/App_Data/Umbraco.sdf
Binary file not shown.
2 changes: 1 addition & 1 deletion AchmeErrorSite/Global.asax
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<%@ Application Inherits="AchmeErrorSite.SiteApplication" Language="C#" %>
<%@ Application Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %>

36 changes: 0 additions & 36 deletions AchmeErrorSite/SiteApplication.cs

This file was deleted.

11 changes: 7 additions & 4 deletions AchmeErrorSite/Views/Home.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Layout = null;
}
<p>Hello</p>
<p><a href="/razorerror">Trigger razor error</a></p>
<p><a href="/compilederror">Trigger compiled error</a></p>
<p><a href="/thisisnotthere">Trigger Umbraco 404</a></p>
<p><a href="/Media/thisisnotthere.jpg">Trigger Media 404</a></p>
<p><a href="/umbraco/">Umbraco</a> login: admin@example.com / 12345678</p>
<p><a href="/razorerror">Trigger razor error</a> (Should respond with 500 status)</p>
<p><a href="/compilederror">Trigger compiled error</a> (Should respond with 500 status)</p>
<p><a href="/foo&lt;script&gt;">Trigger Request Validation error</a> (Should respond with 400 status)</p>
<p>To trigger an IIS 500, rename Umbraco.Core.dll to Umbraco.Core.dll.bak (Should respond with 500 status)</p>
<p><a href="/thisisnotthere">Trigger Umbraco 404</a> (Should respond with 404 status)</p>
<p><a href="/Media/thisisnotthere.jpg">Trigger Media 404</a> (Should respond with 404 status)</p>
4 changes: 3 additions & 1 deletion AchmeErrorSite/Views/RazorError.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@{
Layout = null;
Layout = null;

string foo = null;
foo.Split(',');

//throw new HttpException(500,"arrrgh");
}

<p>Razor error</p>
5 changes: 5 additions & 0 deletions AchmeErrorSite/Views/notfound.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@{
Layout = null;
}

<h2>Umbraco custom 404</h2>
20 changes: 19 additions & 1 deletion AchmeErrorSite/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@
</system.net>

<system.web>
<customErrors mode="On" />
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/500.aspx">
<error statusCode="400" redirect="~/400.aspx"/>
<error statusCode="404" redirect="~/404.aspx"/>
<error statusCode="500" redirect="~/500.aspx"/>
</customErrors>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
<httpRuntime requestValidationMode="2.0" enableVersionHeader="false" targetFramework="4.5" maxRequestLength="51200" fcnMode="Single" />
<!--
Expand Down Expand Up @@ -347,6 +351,12 @@
</requestFiltering>
</security>

<httpErrors errorMode="Custom" existingResponse="Auto" >
<remove statusCode="404"/>
<error statusCode="404" path="404.html" responseMode="File"/>
<remove statusCode="500"/>
<error statusCode="500" path="500.html" responseMode="File"/>
</httpErrors>
</system.webServer>

<runtime>
Expand Down Expand Up @@ -469,6 +479,14 @@
</assemblyBinding>
</runtime>

<location path="media">
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404"/>
<error statusCode="404" path="404.html" responseMode="File"/>
</httpErrors>
</system.webServer>
</location>
<location path="umbraco">
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
Expand Down
4 changes: 2 additions & 2 deletions AchmeErrorSite/config/umbracoSettings.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<content>

<errors>
<error404>1</error404>
<error404>1063</error404>
<!--
The value for error pages can be:
* A content item's integer ID (example: 1234)
Expand Down Expand Up @@ -153,7 +153,7 @@
path, eg http://mysite.com/umbraco. NOT just "mysite.com" or "mysite.com/umbraco" or "http://mysite.com".
-->
<web.routing
trySkipIisCustomErrors="false"
trySkipIisCustomErrors="true"
internalRedirectPreservesTemplate="false" disableAlternativeTemplates="false" disableFindContentByIdPath="false"
umbracoApplicationUrl="">
</web.routing>
Expand Down

0 comments on commit fe02ff7

Please sign in to comment.