Last active
September 24, 2018 01:23
-
-
Save dumbledad/d86875638be358fad0b4b0c7fc5f27d9 to your computer and use it in GitHub Desktop.
Debugging CGI error on swapping from ASP .Net Core 1.0.0-rc2-final to 1.0.0 causes
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
{ | |
"dependencies": { | |
"Dapper": "1.50.0-rc3", | |
"MathNet.Numerics": "3.12.0", | |
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0", | |
"Microsoft.AspNetCore.Authentication": "1.0.0", | |
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0", | |
"Microsoft.AspNetCore.Diagnostics": "1.0.0", | |
"Microsoft.AspNetCore.Mvc": "1.0.0", | |
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", | |
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", | |
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", | |
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0", | |
"Microsoft.AspNetCore.StaticFiles": "1.0.0", | |
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", | |
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", | |
"Microsoft.Extensions.Configuration.Json": "1.0.0", | |
"Microsoft.Extensions.Logging": "1.0.0", | |
"Microsoft.Extensions.Logging.Console": "1.0.0", | |
"Microsoft.Extensions.Logging.Debug": "1.0.0", | |
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", | |
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final", | |
"Microsoft.IdentityModel.Tokens": "5.0.0", | |
"Microsoft.NETCore.App": { | |
"version": "1.0.0", | |
"type": "platform" | |
}, | |
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0", | |
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview2-final", | |
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview2-final", | |
"System.Drawing.Primitives": "4.0.0", | |
"System.Runtime.Serialization.Json": "4.0.2", | |
"WindowsAzure.Storage": "7.1.3-preview" | |
}, | |
"tools": { | |
}, | |
"frameworks": { | |
"netcoreapp1.0": { | |
"imports": [ | |
"dotnet5.6", | |
"dnxcore50", | |
"portable-net45+win8" | |
] | |
} | |
}, | |
"buildOptions": { | |
"emitEntryPoint": true, | |
"preserveCompilationContext": true | |
}, | |
"runtimeOptions": { | |
"gcServer": true | |
}, | |
"publishOptions": { | |
"include": [ | |
"wwwroot", | |
"Views", | |
"config.json", | |
"web.config" | |
] | |
}, | |
"scripts": { | |
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] | |
} | |
} |
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 System; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Configuration; | |
using ThingaMeASPy8s.Settings; | |
using ThingaMeASPy8s.Exceptions; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.IdentityModel.Tokens; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.ApplicationInsights.AspNetCore; | |
using System.IO; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json.Serialization; | |
namespace ThingaMeASPy8s | |
{ | |
public class Startup | |
{ | |
private IConfiguration Configuration { get; set; } | |
public Startup(IHostingEnvironment env) | |
{ | |
Configuration = new ConfigurationBuilder() | |
.SetBasePath(env.ContentRootPath) | |
//.AddJsonFile("config.json", optional: true, reloadOnChange: true) | |
//.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true) | |
.AddJsonFile("config.json") | |
.AddEnvironmentVariables() | |
.Build(); | |
} | |
// This method gets called by the runtime. Use this method to add services to the container. | |
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddOptions(); | |
var appSettings = Configuration.GetSection("AppSettings"); | |
services.Configure<AppSettings>(appSettings); | |
services.Configure<DefaultConnection>(Configuration.GetSection("Data:DefaultConnection")); | |
services | |
.AddMvc() | |
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); | |
services.AddAuthentication(); | |
services.AddApplicationInsightsTelemetry(Configuration); | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
app.UseApplicationInsightsRequestTelemetry(); | |
app.UseApplicationInsightsExceptionTelemetry(); | |
//app.UseWelcomePage(); | |
app.Use(async (context, next) => | |
{ | |
try | |
{ | |
await next(); | |
} | |
catch (Exception ex) | |
{ | |
if (context.Response.HasStarted) | |
{ | |
throw; | |
} | |
int statusCode = 500; | |
if (ex is SecurityTokenInvalidSignatureException || | |
ex is SecurityTokenInvalidLifetimeException || | |
ex is SecurityTokenExpiredException) | |
{ | |
statusCode = 401; | |
} | |
else if (ex is ResourceNotAuthorizedException) | |
{ | |
statusCode = 403; | |
} | |
else if (ex is ResourceNotFoundException || ex is UserDoesNotExistException) | |
{ | |
statusCode = 404; | |
} | |
context.Response.StatusCode = statusCode; | |
await context.Response.WriteAsync(new ExceptionResponse(statusCode, ex).ToString()); | |
} | |
}); | |
// This adds the bearer checking stuff. It must go before | |
// app.UseMvc... | |
app.UseJwtBearerAuthentication(new JwtBearerOptions | |
{ | |
//[SNIP] | |
}); | |
app.UseDefaultFiles(); | |
app.UseStaticFiles(); | |
app.UseMvc(routes => | |
{ | |
//[SNIP] | |
}); | |
if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) | |
{ | |
app.UseDeveloperExceptionPage(); | |
//app.UseRuntimeInfoPage(); // default path is /runtimeinfo | |
} | |
} | |
// Entry point for the application. | |
public static void Main(string[] args) | |
{ | |
var host = new WebHostBuilder() | |
.UseKestrel() | |
.UseContentRoot(Directory.GetCurrentDirectory()) | |
.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="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/> | |
</handlers> | |
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment