When running an ASP.NET Core website in IIS, you may experience the following error:

“HTTP Error 500.19 – Internal Server Error” (Code: 0x8007000d)

The following article describes the error as being “This problem occurs because the ApplicationHost.config file or the Web.config file contains a malformed XML element.”:

This comes down to the presence of the following tag:

<aspNetCore processPath=".\MyWebsite.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />

You’ll need to install the “ASP.NET Core/.NET Core: Runtime & Hosting Bundle” on to the server. This is found on the .NET downloads website and can be located by following the link at “Can’t find the file you want? Find more in .NET Core 2.2 downloads.”.

Here’s a small code snippet to use Http Range Requests with ASP.NET Core butchered from this now outdated MSDN article:

using System.IO;
using System.Text;
using Microsoft.AspNetCore.Mvc;

namespace WebApiRangeTest.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class RangeController : ControllerBase
    {
        private static readonly byte[] _content = Encoding.UTF8.GetBytes("abcdefghijklmnopqrstuvwxyz");

        public IActionResult Get()
        {
            MemoryStream stream = new MemoryStream(_content);

            if (stream == null)
            {
                return NotFound();
            }

            return File(stream, "text/plain", enableRangeProcessing: true);
        }
    }
}

 

The “Request.Headers.Range” method has now been replaced by opting in for this functionality using the enableRangeProcessing boolean when returning a FileStreamResult object.

Have fun!

Step 1 – Starting with the Tools menu item from the top navigation menu, navigate through the menus as follows:

Tools > Options > Text Editor > C# > Code Style > Naming

Step 2 – Click the green Plus icon to open the following dialogue box:

Step 3 – Now add the following:

Step 4 – Create the configuration to use the naming style we’ve just created.

Step 5 – Use the “Create and initialize field”option as normal and you’ll see the following.