Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
/MvcPublic archive
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Zero Content-Length for static file 304 #6875

Closed
Assignees
jbagga
@Tratcher

Description

@Tratcher

From@rustamkulenov on September 22, 2017 8:29

I've developed SPA application (ASP core,MVC,Angular) on Windows but can not host it on Linux. When I reload webpage in browser by F5 Kestrel prints out error and webbrowser receives HTTP code 500. This happens every second reload.

fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HL81HU49MSPA", Request id "0HL81HU49MSPA:00000002": An unhandled exception was thrown by the application.
System.InvalidOperationException: Response Content-Length mismatch: too few bytes written (0 of 42).

Environment:

#dotnet --info

.NET Command Line Tools (2.0.0)

Product Information:
Version: 2.0.0
Commit SHA-1 hash: cdcd1928c9

Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/2.0.0/

Microsoft .NET Core Shared Framework Host

Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Steps to reproduce:

  1. Create new MVC application:
    #dotnet new mvc
  2. Place file named 1.txt with any content into wwwroot
  3. Change Home/Index controller method to:

public IActionResult Index()
{
return File("~/1.txt", "text/plain");
}

  1. #dotnet run

Now, If you try to open localhost:5000 browser will show content of the 1.txt, if you press F5 it'll show error 500. Press F5 again and it'll display content of 1.txt again, etc...

I tried to change Startup.cs to (as stated in#1289 ):

app.UseStaticFiles(new StaticFileOptions(){
OnPrepareResponse=context=>{
context.Context.Response.Headers.Remove("Content-Length");
}
});

, but this does not help.

If I set breakpoint in Home/Index controller method it is hit every time (i.e. on every reload). But it returns content-length=0 on every even reload. On every odd reload it returns correct value.

Copied from original issue:aspnet/KestrelHttpServer#2082

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp