The type String cannot be constructed. You must configure the container to supply this value.

If you are getting below error message

(

The type String cannot be constructed. You must configure the container to supply this value.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The type String cannot be constructed. You must configure the container to supply this value.

)

while creating WEB Api with Unity framework. It can be fixed by just removing below constructors from ~Areas.HelpPage.Controllers.HelpController


 public HelpController()
 : this(GlobalConfiguration.Configuration)
 {
 }

 public HelpController(HttpConfiguration config)
 {
 Configuration = config;
 }

and then override configuration property as and build you project :)-


protected static HttpConfiguration Configuration
{
  get { return GlobalConfiguration.Configuration; }
}

Programming is Easy…

Advertisements

Error when upgrading to WebAPI 2.1 XmlDocumentationProvider does not implement interface member GetDocumentation

If you are getting this error in WEBAPI test client the you can try this-

Install-Package Microsoft.AspNet.WebApi.HelpPage -Pre

Programming is Easy…