aspnet / Razor

[Archived] Parser and code generator for CSHTML files used in view pages for MVC web apps. Project moved to https://github.com/aspnet/AspNetCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'ERR_INCOMPLETE_CHUNKED_ENCODING' error on chrome console

cryeshiren opened this issue · comments

commented

I have a razor page

@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@{
    Layout = "~/Views/Shared/_ForgetPasswordLayout.cshtml";
    var redirectUrl = ViewBag.RedirectUrl ?? Url.Content("~/Account/Login");
}

<title>@Localizer["ConfirmEmail_Confirmation_Title"]</title>
<div class="site-body container-left">
    <div class="form-container">
        <h2>@Localizer["ConfirmEmail_Confirmation_Title"]</h2>
        <p>
            @Localizer["ConfirmEmail_Confirmation_Hint_1"] <a href="@redirectUrl">@Localizer["ConfirmEmail_Confirmation_Hint_2"]</a>
        </p>
    </div>
</div>

when i request it ,an error 'ERR_INCOMPLETE_CHUNKED_ENCODING' occurred on the Google console,
this error does not occur every time

my errorhandlingmiddleware get a error message:

Input string was not in a correct format.: System.FormatException: Input string was not in a correct format.
   at System.Text.StringBuilder.FormatError()
   at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at Microsoft.AspNetCore.Html.HtmlFormattableString.WriteTo(TextWriter writer, HtmlEncoder encoder)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewBuffer.WriteToAsync(TextWriter writer, HtmlEncoder encoder)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIIndexMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext)
   at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
   at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
   at GrapeLEAF.GLAS.ErrorHandlingMiddleware.Invoke(HttpContext context) in xxxMiddleware.cs:line 46

how can I resolve it?

lib -> .net core 2.1

commented

Thank you for filing this issue, @cryeshiren. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem.

commented

I can't provide the project for you, because that project is a company internal project. But I can provide some detail for you.
I have a controller, like 'AccountController', there are some method inside, like 'ForgotPassword', 'ConfirmEmail'...
That methods just show the simple page. The page contains elements of globalization. (But I dont't think the reason is globalization because this problem all occurs in English or other languages.)
Then, at sometimes, my error handle middleware catch the exception above.
I got some information from the above exception message. I think the ‘WriteToAsync’ method which in ViewBuffer.cs has an exception.
the code in ViewBuffer.CS

public async Task WriteToAsync(TextWriter writer, HtmlEncoder encoder)
    {
      if (writer == null)
        throw new ArgumentNullException(nameof (writer));
      if (encoder == null)
        throw new ArgumentNullException(nameof (encoder));
      for (int i = 0; i < this.Count; ++i)
      {
        ViewBufferPage page = this[i];
        for (int j = 0; j < page.Count; ++j)
        {
          ViewBufferValue viewBufferValue = page.Buffer[j];
          string str;
          if ((str = viewBufferValue.Value as string) != null)
          {
            await writer.WriteAsync(str);
          }
          else
          {
            ViewBuffer viewBuffer;
            if ((viewBuffer = viewBufferValue.Value as ViewBuffer) != null)
            {
              await viewBuffer.WriteToAsync(writer, encoder);
            }
            else
            {
              IHtmlContent htmlContent;
              if ((htmlContent = viewBufferValue.Value as IHtmlContent) != null)
              {
                htmlContent.WriteTo(writer, encoder);
                await writer.FlushAsync();
              }
            }
          }
        }
        page = (ViewBufferPage) null;
      }
    }

Please check it, thank you :)

commented

Thanks, @cryeshiren.
@NTaylorMullen, is there enough data for you to investigate this?

Hi @cryeshiren this can occur when there's an unhandled exception thrown on the server. Could you add logging and see if there's an unhnadled exception in the log?

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1

commented

@NTaylorMullen Thanks, I solved this problem, this is a globalization problem. The resource file has some issues.