Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart application gives HttpSysException The prefix is already registered #60107

Open
1 task done
rgroenewoudt opened this issue Jan 30, 2025 · 1 comment
Open
1 task done
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@rgroenewoudt
Copy link

Is there an existing issue for this?

  • 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

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jan 30, 2025
@rgroenewoudt
Copy link
Author

HttpSysListener registers the url prefixes on start.

HttpSysListener.Start() is called in MessagePump.StartAsync() but HttpSysListener.Stop() is not called in MessagePump.StopAsync(). The url prefixes are not unregistered when stopping the application, only when disposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

1 participant