Ensure that HttpConfiguration.EnsureInitialized()

前端 未结 14 1057
一生所求
一生所求 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:41

    For me, the problem was that I was trying to use named parameters for query string fields in my routes:

    [Route("my-route?field={field}")]
    public void MyRoute([FromUri] string field)
    {
    }
    

    Query string fields are automatically mapped to parameters and aren't actually part of the route definition. This works:

    [Route("my-route")]
    public void MyRoute([FromUri] string field)
    {
    }
    

提交回复
热议问题