0

How do I utilize CreateDefaultBuilder when running TestServer?

TestServer _server = new TestServer(new WebHostBuilder() .CreateDefaultBuilder(args) .UseContentRoot("C:\\TestAPI\\TestAPI.WebAPI") .UseEnvironment("Development") 

Error:

'WebHostBuilder' does not contain a definition for 'CreateDefaultBuilder' and no accessible extension method 'CreateDefaultBuilder' accepting a first argument of type 'WebHostBuilder' could be found

This is for Webhost Builder not Webhost, so its not a duplicate question.

1

1 Answer 1

0

You're creating a new instance of WebHostBuilder and trying to call a method on that WebHostBuilder. The WebHostBuilder class does not contain a method CreateDefaultBuilder()

WebHost.CreateDefaultBuilder(...) returns an instance of IWebHostBuilder.
You want to use WebHost.CreateDefaultBuilder(...)

Sign up to request clarification or add additional context in comments.

1 Comment

i do that and it says now, cannot create instance of static webhost