Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with DeveloperExceptionPageMiddleware (ASP.NET 5) #6

Closed
justdmitry opened this issue Mar 24, 2016 · 2 comments
Closed

Comments

@justdmitry
Copy link

In my Startup.cs I have Configure method like this:

app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseDeveloperExceptionPage();
app.UseIdentity()
app.UseRequestLocalization(...);
app.UseWebMarkupMin();
app.UseMvc(...);

I use WebMarkupMin only for MVC content (because all static files are already compressed/minified), but I want to use DeveloperExceptionPageMiddleware (app.UseDeveloperExceptionPage()) earlier in pipeline, because I want it to handle exceptions in identity/auth/... middleware too.

With this config, if any exception occurs (in MVC) - server returns blank page and I see exception in console window from DeveloperExceptionPageMiddleware:

fail: Microsoft.AspNet.Diagnostics.DeveloperExceptionPageMiddleware[0]
An exception was thrown attempting to display the error page.
System.ArgumentException: Stream was not writable.
at System.IO.StreamWriter..ctor(Stream stream, Encoding encoding, Int32 bufferSize, Boolean leaveOpen)
at Microsoft.AspNet.Diagnostics.Views.BaseView.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()

I guess this happens because WebMarkupMin already wrote compressed content (empty page?) into output response stream, and DeveloperExceptionPageMiddleware can't re-write this stream again.

Exception page shows successfully if I move UseDeveloperExceptionPage() after UseWebMarkupMin(), like this:

app.UseWebMarkupMin();
app.UseDeveloperExceptionPage();
app.UseMvc(...)

But I lose any details about exceptions in non-MVC middleware.

@justdmitry
Copy link
Author

I tried to place UseDeveloperExceptionPage() immediately before UseWebMarkupMin() - problem still here, DeveloperExceptionPageMiddleware fails and error page not rendered.

This means that other middleware (UseIdentity, UseRequestLocalization) are not "guilty".

Taritsyn added a commit that referenced this issue Mar 24, 2016
@Taritsyn
Copy link
Owner

Hello, Dmitry!

In WebMarkupMin 2.0.0 RC 5 fixed this error.

Thanks for information!

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

No branches or pull requests

2 participants