1

I am working on jwt login session management with .net core 2.1 backend and angular 6 front-end , when i send the jwt my browser throws this error et::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK). But by checking on postman it works properly. This started to happen since i added a middleware in my backend code which handles the tokens

Error Screenshot

Middleware Code:

 public class JwtTokenMiddleware : IMiddleware
     {
    private readonly ISessionManager _sessionManager;

    public JwtTokenMiddleware(ISessionManager sessionManager)
    {
        _sessionManager = sessionManager;
    }

    public async Task InvokeAsync(HttpContext context, RequestDelegate next)
    {
        if (context.Request.Path.Value.Contains("/api/values/loginuser"))
        {
            await next(context);

        }
        else if (_sessionManager.IsCurrentActiveToken())
        {
            _sessionManager.UpdateTokenExpiryTime();
            await next(context);
        }


        context.Response.StatusCode = (int)HttpStatusCode.OK;
        context.Response.ContentType = "application/json";

        await context.Response.WriteAsync(new ErrorDetails()
        {
            StatusCode = (int)HttpStatusCode.Unauthorized,
            Type = 3,
            Message = "Expired Token"
        }.ToString());
    }

Update: My code works perfectly fine if i remove the middleware , The issue is not because of the transfer-encoding = chunked. But the middleware is very important to my code

Problem Resolved: The issue was that my backend was taking a lot of time to give the response So, i had to optimize the code so that it gives the output under 300 ms of time

Harsh Nagalla
  • 1,198
  • 5
  • 14
  • 26
  • Check this issue first: https://stackoverflow.com/questions/22219565/iis-chrome-failed-to-load-resource-neterr-incomplete-chunked-encoding. Also check contents of Startup.cs and other settings too. – Tetsuya Yamamoto Oct 31 '18 at 08:03
  • Is this much detail enough for it to be removed from hold? – Harsh Nagalla Nov 01 '18 at 03:34

1 Answers1

-1

That could be anything, even antivirus/firewall issue. Try to provide more details please, like, does this happens in Firefox? Can you debug the server? Replace the token?

Dima Shivrin
  • 99
  • 2
  • 11
  • It happens in all browsers, it started to happen when i put asynchronous functions in my middleware to handle the jwt , yes i tried replacing the token with a string to check it works fine – Harsh Nagalla Oct 31 '18 at 15:29