dotvvm
dotvvm copied to clipboard
System.InvalidOperationException: Headers are read-only, response has already started.
I'm just doing this in a click event
public void Giris()
{
Context.RedirectToRoute("Default");
}
it runs correctly when hit f5,
but dotnet watch run
throws an exception:
Session started; Key:99b25544-ff98-e5c7-edd4-5f0d1313b53c, Id:0054525a-8686-a19b-bcaf-96f85d26cbe4
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM6U6GQN7U2R", Request id "0HM6U6GQN7U2R:0000000D": An unhandled exception was thrown by the application.
System.InvalidOperationException: Headers are read-only, response has already started.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_Item(String key, StringValues value)
at Microsoft.AspNetCore.Http.DefaultHttpResponse.set_ContentType(String value)
at DotVVM.Framework.Hosting.DotvvmHttpResponse.set_ContentType(String value)
at DotVVM.Framework.Runtime.DefaultOutputRenderer.WriteViewModelResponse(IDotvvmRequestContext context, DotvvmView view)
at DotVVM.Framework.Hosting.DotvvmPresenter.ProcessRequestCore(IDotvvmRequestContext context)
at DotVVM.Framework.Hosting.DotvvmPresenter.ProcessRequestCore(IDotvvmRequestContext context)
at DotVVM.Framework.Hosting.DotvvmPresenter.ProcessRequest(IDotvvmRequestContext context)
at DotVVM.Framework.Hosting.Middlewares.DotvvmRoutingMiddleware.Handle(IDotvvmRequestContext context)
at DotVVM.Framework.Hosting.Middlewares.DotvvmRoutingMiddleware.Handle(IDotvvmRequestContext context)
at DotVVM.Framework.Hosting.DotvvmMiddleware.Invoke(HttpContext context)
at DotVVM.Framework.Hosting.Middlewares.DotvvmErrorPageMiddleware.Invoke(HttpContext context)
at DotVVM.Framework.Hosting.Middlewares.DotvvmErrorPageMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 885.7518ms 200 application/json
will i get this exception when publish to example.com on IIS server?
I've never seen such exception on IIS. I can see some dotnet watch
entry in the stack trace - we should investigate what's the problem:
Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(HttpContext context)
in login.dothml (inherits MasterPageBos.dotmaster) Context.RedirectToRoute("Default"); or Context.RedirectToUrl("/"); must go to Default.dothtml (inherits MasterPageMain.dotmaster)
maybe different masterpage causes error
I was not able to replicate this issue. Does it still cause problems? If so, could you provide more information about the environment and setup you have encountered this exception?
I've never seen such exception on IIS. I can see some
dotnet watch
entry in the stack trace - we should investigate what's the problem:Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware.InvokeAsync(HttpContext context)
For me it happened in ubuntu 20.04
I was not able to replicate this issue. Does it still cause problems? If so, could you provide more information about the environment and setup you have encountered this exception?
Also happened for me in ubuntu 20.04 dotnet 5.0
Yes, this happens on Ubuntu 20.04 with dotnet 6 as well.
What is your version of DotVVM NuGet package? I think we already fixed this issue.
Yes, I had to shuffle the middle ware above endpoint routing Middleware and it was no longer an issue.
Regards Sen
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Tomáš Herceg @.> Sent: Monday, August 29, 2022 12:24:48 PM To: riganti/dotvvm @.> Cc: Sen Gupta @.>; Comment @.> Subject: Re: [riganti/dotvvm] System.InvalidOperationException: Headers are read-only, response has already started. (#958)
What is your version of DotVVM NuGet package? I think we already fixed this issue.
— Reply to this email directly, view it on GitHubhttps://github.com/riganti/dotvvm/issues/958#issuecomment-1229855266, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB5R3ZQ7BE34LTMMTU5BRZLV3RNDRANCNFSM4YRAZHOA. You are receiving this because you commented.Message ID: @.***>