允许在Visual Studio Express 2013 for Web中加载JSON文件 [英] Allow loading of JSON files in Visual Studio Express 2013 for Web

查看:248
本文介绍了允许在Visual Studio Express 2013 for Web中加载JSON文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是,Visual Studio Express 2013 for Web中的IIS不允许加载* .json文件。当我尝试加载* .json文件时,我得到403 Forbidden和帮助页面如何配置IIS允许加载JSON文件,但不知道如何处理这些信息/ IIS所在的位置。

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.

这是错误页面:


HTTP错误404.3 - 未找到该页面由于扩展配置,您请求的服务不能是
。如果页面是
脚本,请添加处理程序。如果要下载该文件,请添加MIME
映射。

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.

最有可能的原因:可能缺少处理程序映射。
默认情况下,静态文件处理程序处理所有内容。您尝试使用的功能
可能未安装。没有为网站或应用程序启用适当的MIME映射
。 (警告:不要
为用户不应下载的内容创建MIME映射,例如
.ASPX页面或.config文件。)如果未安装ASP.NET。

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.

您可以尝试的事项:在system.webServer / handlers中:确保映射当前页面的
预期处理程序。额外注意
到前提条件(例如,runtimeVersion,pipelineMode,bitness)
并将它们与应用程序池的设置进行比较。额外支付
注意预期处理程序行中的打字错误。请
验证您正在尝试使用的功能是否已安装。验证
是否启用了MIME映射,或使用命令行工具appcmd.exe为网站
添加MIME映射。要设置MIME类型,请在IIS Express安装目录中运行
以下命令:appcmd set
config / section:staticContent
/ + [fileExtension ='string',mimeType ='string' ]变量
fileExtension字符串是文件扩展名,变量
mimeType字符串是文件类型描述。例如,要为扩展名为.xyz的文件添加
MIME映射:appcmd set config
/ section:staticContent /+[fileExtension='.xyz',mimeType='text/ plain']
警告:在将Web服务器
添加到列表之前,请确保需要此MIME映射。配置文件,如.CONFIG或
动态脚本页面,如.ASP或.ASPX,不应直接下载
,应始终通过处理程序处理。
其他文件(如数据库文件或用于存储
配置的文件,如.XML或.MDF)有时用于存储
配置信息。确定客户端是否可以在启用它们之前下载这些
文件类型。安装ASP.NET。检查失败的
请求跟踪日志,以获取有关此错误的其他信息。有关
的更多信息,请单击此处。

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.

详细错误信息:模块StaticFileModule通知

ExecuteRequestHandler处理程序StaticFile错误代码0x80070032
请求的URL http://localhost:64107/Settings/Settings.json
物理路径D:\ GIT \ RepoP_Paneon \ Settingtings \设置.json登录
方法匿名登录用户匿名请求跟踪目录

C:\ Users\stefank \Documents\IExExpress\TraceLogFiles\REPOP_PANEON

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

更多信息:当此错误发生时
请求的URL的文件扩展名是针对未在服务器上配置的MIME类型。
您可以为不是
动态脚本页面,数据库或配置文件的文件添加文件扩展名的MIME类型。使用处理程序处理
这些文件类型。您不应该允许直接
下载动态脚本页面,数据库或配置文件。
查看更多信息»

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 »


推荐答案

经过一番谷歌搜索和实验,我找到了out,你必须在 Web.config 中定义IIS设置。

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

添加以下配置后:

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

它就像魅力一样。

完整安装文件示例:

<?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>

这篇关于允许在Visual Studio Express 2013 for Web中加载JSON文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆