my webapi application, runs fine when launched visual studio throws following error when running on owin self host:
"no connection string named 'productsdbcontext' found in application config file."
does owin need configuration access web.config file?
here startup.cs:
public void configuration(iappbuilder appbuilder) { // configure web api self-host. var config = new httpconfiguration(); webapiconfig.register(config); unityconfig.registercomponents(config); appbuilder.usewebapi(config); }
and self host code:
[testmethod] public void listscorecardslices() { var baseaddress = "http://localhost:9000/"; // start owin host using (webapp.start<startup>(baseaddress)) { httpclient client = new httpclient(); var response = client.getasync(baseaddress + "api/products(2)").result; var responsebody = response.content.readasstringasync().result; assert.areequal(httpstatuscode.ok, response.statuscode); } }
if hosting owin in kind of service or non-web application (which likely, because why else need self-host), you'd need not web.config
file, application config file, has name of <your executable name extension>.config
. if add app.config
file executable project, visual studio automatically place executable.
Comments
Post a Comment