Restart application gives HttpSysException The prefix is already registered
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I would like to start and stop our application on demand, without exiting the process. Code would be similar like:
```
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseHttpSys();
builder.Services.AddControllers();
var app = builder.Build();
await app.StartAsync();
await app.StopAsync();
// Something here
await app.StartAsync();
```
However, with http.sys this gives an exception: `Microsoft.AspNetCore.Server.HttpSys.HttpSysException: 'The prefix 'http://localhost:5074/' is already registered.'`.
Minimum testcase: [WebApplication2.zip](https://github.com/user-attachments/files/18603722/WebApplication2.zip)
Is there any way to restart the app or a workaround to make this work?
### Expected Behavior
_No response_
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
9.0.102
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.