Thursday, April 14, 2016

Could not parse the JSON file. AspNet.Hosting requires Hosting.ini to be in JSON format


Problem: 

After asp.net beta8 the format of the hosting.ini file is required to be JSON
You will get the error below if this isn't changed:
System.FormatException: Could not parse the JSON file. Error on line number '0': 'server=Microsoft.AspNet.Server.WebListener'. ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: s. Path '', line 0, position 0.

Solution: 

Change the hosting.ini file to json format. The file is used if you are self-hosting your web server using AspNet.Hosting and referencing the file in project.json like below.



In my version (rc1-update1) of ASP.NET this no longer works without converting the hosting.ini file to json.