Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow loading of JSON files in Visual Studio Express 2013 for Web

I have the problem, that the IIS from Visual Studio Express 2013 for Web doesn't allow the loading of *.json files. When trying to load a *.json file I get a 403 Forbidden and a help page how to configure the IIS allow the loading of JSON files, but don't know what to do with this information / where the IIS is even located.

This is the error page:

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Most likely causes: It is possible that a handler mapping is missing. By default, the static file handler processes all content. The feature you are trying to use may not be installed. The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.) If ASP.NET is not installed.

Things you can try: In system.webServer/handlers: Ensure that the expected handler for the current page is mapped. Pay extra attention to preconditions (for example, runtimeVersion, pipelineMode, bitness) and compare them to the settings for your application pool. Pay extra attention to typographical errors in the expected handler line. Please verify that the feature you are trying to use is installed. Verify that the MIME map is enabled or add the MIME map for the Web site using the command-line tool appcmd.exe. To set a MIME type, run the following command in the IIS Express install directory: appcmd set config /section:staticContent /+[fileExtension='string',mimeType='string'] The variable fileExtension string is the file name extension and the variable mimeType string is the file type description. For example, to add a MIME map for a file which has the extension ".xyz": appcmd set config /section:staticContent /+[fileExtension='.xyz',mimeType='text/plain'] Warning: Ensure that this MIME mapping is needed for your Web server before adding it to the list. Configuration files such as .CONFIG or dynamic scripting pages such as .ASP or .ASPX, should not be downloaded directly and should always be processed through a handler. Other files such as database files or those used to store configuration, like .XML or .MDF, are sometimes used to store configuration information. Determine if clients can download these file types before enabling them. Install ASP.NET. Check the failed request tracing logs for additional information about this error. For more information, click here.

Detailed Error Information: Module StaticFileModule Notification
ExecuteRequestHandler Handler StaticFile Error Code 0x80070032 Requested URL http: //localhost:64107/Settings/Settings.json Physical Path D:\GIT\RepoP_Paneon\Settings\Settings.json Logon Method Anonymous Logon User Anonymous Request Tracing Directory
C:\Users\stefank\Documents\IISExpress\TraceLogFiles\REPOP_PANEON

More Information: This error occurs when the file extension of the requested URL is for a MIME type that is not configured on the server. You can add a MIME type for the file extension for files that are not dynamic scripting pages, database, or configuration files. Process those file types using a handler. You should not allows direct downloads of dynamic scripting pages, database or configuration files. View more information »

like image 328
Stefan Avatar asked Oct 22 '13 11:10

Stefan


People also ask

How to set JSON format in Visual Studio code?

You can format your JSON document using Ctrl+Shift+I or Format Document from the context menu.

What is JSON file in VSCode?

json extension, VS Code provides features that make it simpler to write or modify the file's content. In this article, we will show you a few ways to quickly format JSON files into human-readable syntax with proper indentation in VSCode. Contents hide. 1 JSON indentation standard. 2 VSCode Format JSON Keyboard Shortcut.


1 Answers

After some more googling, and experimenting I found out, that you have to define IIS settings in the Web.config.

After adding the following configuration:

  <system.webServer>     <staticContent>       <mimeMap fileExtension=".json" mimeType="application/json" />     </staticContent>   </system.webServer> 

it works like a charm.

Full setup file example:

<?xml version="1.0"?> <configuration>   <system.web>     <compilation debug="true" targetFramework="4.0"/>   </system.web>   <system.webServer>     <staticContent>       <mimeMap fileExtension=".json" mimeType="application/json" />     </staticContent>   </system.webServer> </configuration> 
like image 180
Stefan Avatar answered Oct 25 '22 07:10

Stefan