NickCraver/StackExchange.Exceptional

Compatibility issues using Exceptional with ASP.NET Core 2.2

Closed this issue · 6 comments

Just upgraded a project to use ASP.NET Core 2.2, and I'm getting really weird behaviors with Exceptional. The CSS and JS aren't loading for one, Which I suspect might be due to routing changes in 2.2, and a few other odd behaviors like being able to see the list of exceptions (obviously minus css), but clicking to view a specific error gives me a 404. Again, I suspect this is due to routing changes in 2.2. I wanted to try and put this here early to ask if Exceptional has been tested with 2.2 yet? I'm using 2.0.0-rc2.28

I've stripped down my action handler for exceptional down to the verbatim example on the https://nickcraver.com/StackExchange.Exceptional/AspDotNetCore#routes page, same problem. Definitely some changes needed to support the new routing I think

I don't think it's exceptional, but I also can't figure out why my code doesn't work anymore?

[Route("~/errors/log/{*resource}", Name="ErrorLog")]

Was using that attribute to control access to the action that forwards off to Exceptional. It works perfectly fine in ASP.NET Core 2.1 (and has for a long time), but for whatever reason, in 2.2 the catch all fails to match any url's with anything after the log/ segment. I honestly have no idea why. I've managed to get it working by removing the attribute and renaming the controller/action to match the route I wanted to use, but I haven't got a clue why. The symptom doesn't seem to be present in a brand new 2.2 project? It's late, my brain is mush. I'll try and fight with it tomorrow. This may not be an issue with Exceptional at all, in which case I may close this once I'm positive.

Any way you can repro this in the sample projects? I can't get it to break but there were routing changes in 2.2 so I don't have trouble believing it broke some scenario.

@nickalbrecht are you still hitting this?

Yes and no. I managed to get it work after upgrading to 2.2 by abandoning my route attribute, but it still doesn't work with one.
My controller looked something like this

public class ErrorsController : Controller
{
	[Route("~/errors/log/{*resource}", Name = "ErrorLog")]
	public async Task Log() => await StackExchange.Exceptional.ExceptionalMiddleware.HandleRequestAsync(HttpContext);
}

But after upgrading to 2.2 the page's HTML would load, but the JS and CSS would result in 404's. The URLs that it's attempting seem correct. For example:
https://localhost:12345/errors/log/css?v=SYe4qyVl3NakTSiCtElGXbzZduqtoiDg7YzqRCfUULlM2RXxZ5fZkDspyuDopkt6FtZ1CASLIHCmW1RrDG+aHw==

But it just doesn't find them. I've tried using {**resource} as well but with no difference. In the end I gave up on the explicitly defining the route, and just left it at at the default convention of [controller]/[action]. Without trying to explicitly set the url, the JS and CSS load correctly.

This was all tested with AspNetCore 2.2.0, StackExchange.Exceptional.AspNetCore 2.0.0, and CompatibilityVersion.Version_2_2

Not sure if this matters or not, but I have my route defined like this (from the sample):

[HttpGet("/dev/errors/{path?}/{subPath?}")]

Main difference I see is missing the subPath segment. Looking at the resources, I'm not sure if that's actually needed or not, but thought I'd share.

I can confirm that using the route params of path and subpath seem to work. Seems that's the trick to be able to customize the route to Exceptional. Going to close this now that this has been found, thanks for the heads up @mmillican

[Route("~/errors/log/{path?}/{subPath?}", Name="ErrorLog")]
[Authorize(Policy = "CanViewErrorLog")]
public async Task Log() => await StackExchange.Exceptional.ExceptionalMiddleware.HandleRequestAsync(HttpContext).ConfigureAwait(false);