dotnet / dotnet/aspnetcore

Hosting the App on IIS cause Server URL to be Uppercase using Server Features

Open
#44,622 8 comments 0 reactions 0 assignees View on GitHub
area-networking feature-iis
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

Hosting ASP.NET Core Application on IIS/IIS Express cause the Application URLs to be Uppercase when using Server Features _IServerAddressesFeature_ to get the list of server addresses.

Code:

```C#
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();
app.UseRouting();

app.MapGet("/", () =>
{
// Get Server address using Server Features...
var server = app.Services.GetRequiredService();
var addressFeature = server.Features.Get();
// Uppercase addresses - using IIS/IIS Express
var addresses = addressFeature!.Addresses.ToList();
return "Listing on addresses: \n" + string.Join("\n", addresses);
});

app.Run();
```

IIS Configuration section in launchsettings.json:
```json
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:39381/AppHomeTest",
"sslPort": 44351
}
}
```

Output:

```
Listing on addresses:
http://localhost:39381/APPHOMETEST
https://localhost:44351/APPHOMETEST
```

### Expected Behavior

The Server URL string should be same as defined in the app configuration or launchsettings.json
Note: This issue does not repro when hosting the application on Kestrel server.

### Steps To Reproduce

Repro app (for IIS/ IIS Express): https://github.com/afifi-ins/ReproUppercaseURLs

Steps to reproduce the issue:

- Build the repro app
- Run the app hosted on IIS / IIS Express profile.

### Exceptions (if any)

_No response_

### .NET Version

7.0.100-rc.1.22431.12

### Anything else?

.NET SDK:
Version: 7.0.100-rc.1.22431.12
Commit: f1cf61e1c0

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\

Host:
Version: 7.0.0-rc.1.22426.10
Architecture: x64
Commit: 06aceb7015

.NET SDKs installed:
3.1.424 [C:\Program Files\dotnet\sdk]
7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

IIS Version 10.0.19041.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.