integrativesoft / lara

Lara Web Engine is a lightweight C# framework for web user interface development.
Apache License 2.0
153 stars 9 forks source link

Headers are read-only, response has already started #102

Closed rachavz closed 3 years ago

rachavz commented 3 years ago

Hi, When debug lara in aspnetcore web project I have the next fail : Headers are read-only, response has already started

trace in the file MiddlewareCommon.cs function

public static async Task WriteBuffer(HttpContext http, byte[] buffer)
        {
            try
            {
                await http.Response.Body.WriteAsync(buffer.AsMemory(0, buffer.Length));
                http.Response.ContentLength = buffer.Length;
            }
            catch (Exception ex)
            {
                throw;   //here put break point
            }
        }
pablocar80 commented 3 years ago

The issue is that if you modify the headers, then that line crashes?

pablocar80 commented 3 years ago

Do you have any more information to reproduce the issue?

rachavz commented 3 years ago

Only show the message every time, I made a simple web project in

https://github.com/rChavz/lara/tree/master/src/SampleWeb

but when run show the message

rachavz commented 3 years ago

if yo have time please check this file

https://github.com/rChavz/lara/blob/master/src/SampleWeb/Pages/CounterPageJson.cs

if you like, we can make some changes for more easy integration

pablocar80 commented 3 years ago

I cloned the repo and had a few compile errors, after fixing them, I am able to execute and run the following:

image

I did not get any errors when clicking.... how do I get the error to show?

pablocar80 commented 3 years ago

@rChavz do you have any other information on this? Thanks!

rachavz commented 3 years ago

what you think about write the ui in json?

pablocar80 commented 3 years ago

Were you able to fix the issue? I could not reproduce it in the sample repo you linked.

About the json question, looks like an interesting approach. There is no syntax checking during compile time. Have you tried using the LaraBuilder class, and if yes, how was your experience with it?

rachavz commented 3 years ago

the message error occurs when debug in netcore app, when run in IISExpress does not appear

pablocar80 commented 3 years ago

Ok I was able to reproduce the error, looking into it

pablocar80 commented 3 years ago

the latest version published on nuget fixes this issue, thank you very much for reporting it @rChavz