Created
August 3, 2016 01:06
-
-
Save shirhatti/e143b773ce9dcfb4b83889966deb7c7f to your computer and use it in GitHub Desktop.
Minimal ASP.NET Core to return 404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "1.0.0-*", | |
"buildOptions": { | |
"emitEntryPoint": true | |
}, | |
"dependencies": { | |
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", | |
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0" | |
}, | |
"frameworks": { | |
"netcoreapp1.0": { | |
"dependencies": { | |
"Microsoft.NETCore.App": { | |
"type": "platform", | |
"version": "1.0.0" | |
} | |
} | |
} | |
}, | |
"publishOptions": { | |
"include": [ | |
"web.config" | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Http; | |
namespace ConsoleApplication | |
{ | |
public class Startup | |
{ | |
public void Configure(IApplicationBuilder app) { | |
app.Run(async (context) => | |
{ | |
context.Response.ContentType = "text/plain"; | |
context.Response.StatusCode = 404; | |
await context.Response.WriteAsync("Custom 404 page"); | |
}); | |
} | |
public static void Main(string[] args) | |
{ | |
var host = new WebHostBuilder() | |
.UseKestrel() | |
.UseIISIntegration() | |
.UseStartup<Startup>() | |
.Build(); | |
host.Run(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<system.webServer> | |
<handlers> | |
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> | |
</handlers> | |
<aspNetCore processPath="dotnet" arguments=".\four-o-four.dll"/> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment