Ensure that HttpConfiguration.EnsureInitialized()

前端 未结 14 1056
一生所求
一生所求 2020-11-30 23:31

I\'ve installed Visual Studio 2013 and when I run my app I get the error below.

I\'ve got no idea as to where I\'m to initialized this object.

What to do?

14条回答
  •  独厮守ぢ
    2020-11-30 23:44

    One typically gets this exception when route templates in "Attribute Routing" are not proper.

    For example, i got this when i wrote the following code:

    [Route("{dirName:string}/contents")] //incorrect
    public HttpResponseMessage GetDirContents(string dirName) { ... }
    

    In route constraints syntax {parameter:constraint}, constraint by default is of type string. No need to mention it explicitly.

    [Route("{dirName}/contents")] //correct
    public HttpResponseMessage GetDirContents(string dirName) { ... }
    

提交回复
热议问题