Ports Fall Silent In ASP.NET Core WebApp Factories
WebApplicationFactoryCreateHost delegates control, overriding child port settings via TryConfigureServerPort, which reads a parent-level _kestrelPort that’s null on derived builds. The workaround? Subclass and override ConfigureWebHost - this captures the subclass’s port directly, bypassing parent delegation. When should you worry? If your test suite relies on precise porting for API integration or local development, this bug breaks consistency. Don’t assume UseKestrel(port) works everywhere - context matters. Use the subclass method when fine-grained port control is essential.