Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Middleware path-based mapping reapplies to PathBase on unhandled exception #4444

Closed
AlexAlappsis opened this issue Apr 11, 2016 · 2 comments
Closed

Comments

@AlexAlappsis
Copy link

When adding a middleware mapping with IApplicationBuilder.Map(), the map path is reflected in HttpContext.Request.PathBase. If the application experiences an unhandled exception, and the IApplicationBuilder isn't setup with an exception handler(i.e. UseDeveloperExceptionPage()) the PathBase will be appended to.
So if my map is "/v1", after an unhandled exception the HttpContext.Request.PathBase will be "/v1/v1" Each unhandled exception will append the mapping.

I've set up a simple sample in a github repo here. https://github.com/AlexAlappsis/AspNetMappingError.

This is a new ASP.NET 5 Web application template that I've pared down. The important parts are in the Startup.cs. In Configure I've added a mapping with the path /v1. In ConfigureSub I've commented out the default error handling.

If you go to localhost/v1 you'll see the pathbase displayed. If you then hit localhost/v1/home/error, it will throw an exception. If you then refresh localhost/v1 you'll see it repeated. I actually saw different results depending on if you're running it in IIS Express or Kestrel. In Kestrel the duplicated pathBase will always display, in IIS Express if you refresh localhost/v1 you'll see it alternate back and forth.

@Eilon
Copy link
Member

Eilon commented Apr 14, 2016

@Tratcher any idea on this? Is this an issue deeper down, such as in Hosting or HttpAbstractions or something?

@Tratcher
Copy link
Member

Duplicate of aspnet/HttpAbstractions#510. Already fixed in RC2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants