Ensure that HttpConfiguration.EnsureInitialized()

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

    If you do it at the end of Application_Start it will be too late, as WebApiConfig.Register has been called.

    The best way to resolve this is to use new initialization method by replacing in Global.asax :

    WebApiConfig.Register(GlobalConfiguration.Configuration);
    

    by

    GlobalConfiguration.Configure(WebApiConfig.Register);
    

提交回复
热议问题