W2K3下配置IIS6支持.json格式文件:
By default, IIS in W2K3 and above won't serve files that aren't of a MIME type that it knows about (instead returning 404 errors). You need to add a MIME type to IIS to allow it to serve that type of file. You can set it at the site level or at the server level. To set this for the entire server:
win7下配置iis支持.json格式的文件: 1、IIS必须开启ASP支持,打开或关闭windows功能——internet信息服务——万维网服务——应用程序开发功能,选择asp,然后确定。
2、Internet信息服务管理器,打开”MIME类型“。点击添加,扩展名写“.json”,MIME类型写”application/x-JavaScript“【不要引号】,然后确定。
3、打开”处理程序映射“,点击”添加脚本映射“,请求路径写”*.json”【不要引号】,可执行文件为“C:\Windows\System32\inetsrv\asp.dll”【通过浏览窗口定位该文件】,名称写“JSON”,再打开请求限制——谓词——下列谓词之一,填写“GET,POST”【不要引号】,两次确定后会弹出提示,点击“是”,然后重启IIS【cmd->"iisreset"】。
4、通过浏览器访问:http://localhost/xxx.json,应该就可以显示json数据了
配置VS IIS Express,支持JSON: 方法有2种: 1. 命令行 a. cd "iis express的安装目录" 例如:cd C:\Program Files (x86)\IIS Express b. appcmd set config /section:staticContent /+[fileExtension='.json',mimeType='application/x-javascript'] c. appcmd set config /section:handlers /+[name='JSON',path='*.json',verb='GET,HEAD,POST,DEBUG',modules='IsapiModule',scriptProcessor='%IIS_BIN%\asp.dll', resourceType='File'] 2. 直接修改配置文件(不建议使用,容易找错配置文件的位置) 正确路径在:%UserProfile%\Documents\IISExpress\config\applicationhost.config a. 在<handlers>节点下面添加:<add name="JSON" path="*.json" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%IIS_BIN%\asp.dll" resourceType="File" /> b. 在<staticContent>节点下面添加:<mimeMap fileExtension=".json" mimeType="application/x-javascript" /> |
|