Azure / WebMatrix web.config 500错误

时间:2013-03-27 05:59:17

标签: azure webmatrix-2

我尝试将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生成。

控制台出错:

获取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中启用了调试,但还找不到错误列表......)

1 个答案:

答案 0 :(得分:0)

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两次,或类似的东西。查看有关如何启用日志记录的this SO question

<强>更新

更新问题后,很明显cars.json不是真正的static文件。所以问题有点混乱。你在这个“文件”中执行什么类型的脚本?

更新2

这是你的json:http://jsonp.azurewebsites.net/demo.json

显然,您对其余网站设置存在问题。正如我所说 - 打开所有日志记录并检查真正的错误消息。