aspnet / StaticFiles

[Archived] Middleware for handling requests for file system resources including files and directories. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
114 stars 72 forks source link

StaticFiles cuting off 3 characters (and sometimes printing a BOM at the beginning) #130

Closed WoMayr closed 8 years ago

WoMayr commented 8 years ago

I am currently trying to migrate a RC1 web application with Angular 2 to RC2. But I have the problem that the StaticFile-Middleware sometimes cuts 3 charactes away from the end. (But the content-length seems to be the same since every browser reports a unexpected EOF). The interesting thing ist that once in a while it also prints a BOM at the beginning.

Also some pages seem to work where others fail.

This is the HTML-Page of the angular component where the error occurs:

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-12">
        <h2><ng-content select="header"></ng-content></h2>
        <ol class="breadcrumb">
            <li><a href="#">Here</a></li>
            <li><a href="#">are</a></li>
            <li><a href="#">the</a></li>
            <li class="active"><a href="#">breadcrumbs</a></li>
        </ol>
    </div>
</div>
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content p-md">
                    <ng-content select="page-body"></ng-content>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="footer">
    <div class="pull-right">
        10GB of <strong>250GB</strong> Free.
    </div>
    <div>
        <strong>Copyright</strong> example company &copy; 2016
    </div>
</div>

I also tried with different browsers, fresh projects and double checked the encodings of those files.


EDIT: Interessting observation: when I delete the <ol>-Element the error disapears...

EDIT 2: When I add the BOM in the actual source file. The characters don't get cut off.

Tratcher commented 8 years ago

This is pretty strange. StaticFiles does not encode or decode files, there's no reason it should ever add a BOM. Are you generating the file and/or frequently editing it?

What's the rest of your setup? Kestrel? Kestrel + IIS / Express? Windows?

WoMayr commented 8 years ago

Windows 10 with Visual Studio 2015.

For testing purposes i have used the stock ASP.Net Core project (MVC Sample app) that ships with the Visual Studio SDK. I haven't changed anything, just added the file above into the wwwroot folder. The bug happens with both Kestrel and IIS Express. The HTML file is self written. I have tried it with Linux and Windows line endings and viewed the files with a binary editor to see if there are any suspicous characters in it.


EDIT: I have attached the solution where this happens: WebApplication2.zip

muratg commented 8 years ago

Investigate for 1.0

pakrym commented 8 years ago

Caused by: https://github.com/aspnet/BrowserLink/issues/24