允许在 Visual Studio Express 2013 for Web 中加载 JSON 文件

本文介绍了允许在 Visual Studio Express 2013 for Web 中加载 JSON 文件的处理方法,对大家解决问题具有一定的参考价值

问题描述

我遇到的问题是,来自 Visual Studio Express 2013 for Web 的 IIS 不允许加载 *.json 文件.尝试加载 *.json 文件时,我收到 403 Forbidden 和帮助页面如何配置 IIS 允许加载 JSON 文件,但不知道如何处理此信息/IIS 甚至位于何处.

这是错误页面:

<块引用>

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

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

您可以尝试的方法:在 system.webServer/handlers 中:确保当前页面的预期处理程序已映射.特别注意前提条件(例如,runtimeVersion、pipelineMode、bitness)并将它们与应用程序池的设置进行比较.额外付费注意预期处理程序行中的印刷错误.请验证您尝试使用的功能是否已安装.核实启用 MIME 映射或为网站添加 MIME 映射使用命令行工具 appcmd.exe.要设置 MIME 类型,请运行在 IIS Express 安装目录中执行以下命令:appcmd set配置/部分:静态内容/+[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.检查失败请求跟踪日志以获取有关此错误的其他信息.为了更多信息,请点击这里.

详细错误信息:Module StaticFileModule Notification
ExecuteRequestHandler 处理程序静态文件错误代码 0x80070032请求的 URL http://localhost:64107/Settings/Settings.json物理路径 D:GITRepoP_PaneonSettingsSettings.json 登录方法匿名登录用户匿名请求跟踪目录
C:UsersstefankDocumentsIISExpressTraceLogFilesREPOP_PANEON

更多信息:当文件扩展名为请求的 URL 用于未在服务器上配置的 MIME 类型.您可以为非以下文件的文件扩展名添加 MIME 类型动态脚本页面、数据库或配置文件.过程那些使用处理程序的文件类型.你不应该允许直接下载动态脚本页面、数据库或配置文件.查看更多信息 »

解决方案

经过更多的谷歌搜索和试验后,我发现您必须在 Web.config 中定义 IIS 设置.

添加如下配置后:

 <静态内容><mimeMap fileExtension=".json" mimeType="application/json"/></staticContent></system.webServer>

它就像一个魅力.

完整的安装文件示例:

<配置><system.web><编译调试="true" targetFramework="4.0"/></system.web><system.webServer><静态内容><mimeMap fileExtension=".json" mimeType="application/json"/></staticContent></system.webServer></配置>

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:GITRepoP_PaneonSettingsSettings.json Logon Method Anonymous Logon User Anonymous Request Tracing Directory
C:UsersstefankDocumentsIISExpressTraceLogFilesREPOP_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 »

解决方案

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>

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

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1155

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1056

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this-&gt;id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:795

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this-&gt;id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:882

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:923

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:867

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:852

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:824

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1683

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1292