![](/img/trans.png)
[英]MVC 4 Azure web role: Error 500 when adding the “tracing” element to web.config
[英]Azure/WebMatrix web.config 500 Error
我试图将MIME类型添加到webmatrix web.config文件中以在Azure中运行:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
但是在尝试加载json文件时出现500(内部服务器错误)。
该站点在本地工作。
我需要在Azure中做其他事情吗?
(编辑:)
我在web.config中拥有的全部是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add invariant="System.Data.SqlServerCe.4.0" name="Microsoft® SQL Server® Compact 4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
没有MIME类型的位是由webMatrix生成的。
控制台错误:
GET http://carlistings.azurewebsites.net/CarListings/data/cars.json?_dc=1364378861597&page=1&start=0&limit=25 500(内部服务器错误)
更新
该文件不会更改,并由Sencha Architect教程应用程序的JavaScript调用。
{
"img" : "2004_Porsche_911_Carrera_type_997.jpg",
"manufacturer" : "Porsche",
"model" : "911",
"price" : 135000,
"wiki" : "http://en.wikipedia.org/wiki/Porsche_997",
"quality" : [{
"name" : "overall",
"rating" : 1
},{
"name" : "mechanical",
"rating" : 4
},{
"name" : "powertrain",
"rating" : 2
},{
"name" : "body",
"rating" : 4
},{
"name" : "interior",
"rating" : 3
},{
"name" : "accessories",
"rating" : 2
}]
}
更新2
我注意到在本地运行应用程序(应用程序正常运行的地方),错误日志将cars.json文件显示为application / json,而在Azure服务器上,它显示为text / html。
看来Azure服务器正在用其他东西忽略我的web.config文件...
(我已经在Azure中启用了调试功能,但是还找不到错误列表...)
HTTP 500来自其他内容。
我恰好在新的空WebSite中添加了您所做的操作,结果与预期的一样。
要测试的网址: http : //jsonp.azurewebsites.net/demo.json
这是来自请求的提琴手跟踪:
GET http://jsonp.azurewebsites.net/demo.json HTTP/1.1
User-Agent: Fiddler
Host: jsonp.azurewebsites.net
响应也与预期的一样:
HTTP/1.1 200 OK
Content-Length: 30
Content-Type: application/json
Last-Modified: Wed, 27 Mar 2013 09:03:09 GMT
Accept-Ranges: bytes
ETag: "cc2c13e7c92ace1:0"
Server: Microsoft-IIS/7.5
.. aditional header omitted for readability
Date: Wed, 27 Mar 2013 09:03:52 GMT
{"title":"demo","count":10}
我建议您打开所有可能的日志记录并检查错误日志。 您很可能两次定义了system.webServer
或类似的东西。 查看有关如何启用日志记录的SO问题 。
更新
更新问题后,很明显cars.json
不是真正的static
文件。 所以问题有点混乱。 您在此“文件”中执行哪种类型的脚本?
更新2
这是您的json: http : //jsonp.azurewebsites.net/demo.json
显然您在其余的网站设置上遇到了问题。 如我所说-打开所有日志记录并检查真正的错误消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.