简体   繁体   English

Azure / WebMatrix web.config 500错误

[英]Azure/WebMatrix web.config 500 Error

I've tried to add a MIME type to the webmatrix web.config file to run in Azure: 我试图将MIME类型添加到webmatrix web.config文件中以在Azure中运行:

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

But I get a 500 (Internal Server Error) when trying to load a json file. 但是在尝试加载json文件时出现500(内部服务器错误)。

The site works locally. 该站点在本地工作。

Is there something else in Azure I need to do? 我需要在Azure中做其他事情吗?

(Edit:) (编辑:)

All I have in web.config is: 我在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>

The bit without the MIME type was generated by webMatrix. 没有MIME类型的位是由webMatrix生成的。

Error in console: 控制台错误:

GET http://carlistings.azurewebsites.net/CarListings/data/cars.json?_dc=1364378861597&page=1&start=0&limit=25 500 (Internal Server Error) GET http://carlistings.azurewebsites.net/CarListings/data/cars.json?_dc=1364378861597&page=1&start=0&limit=25 500(内部服务器错误)

UPDATE 更新

The file doesn't change and is called by JavaScript from a Sencha Architect tutorial app. 该文件不会更改,并由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
}]
}

UPDATE 2 更新2

I've noticed that running the app locally (where the app runs properly) the error log shows the cars.json file as application/json, whereas on the Azure server, it shows it as text/html. 我注意到在本地运行应用程序(应用程序正常运行的地方),错误日志将cars.json文件显示为application / json,而在Azure服务器上,它显示为text / html。

It appears the Azure server is ignoring my web.config file with something else... 看来Azure服务器正在用其他东西忽略我的web.config文件...

(I've enabled debugging in Azure but can't find a list of errors yet...) (我已经在Azure中启用了调试功能,但是还找不到错误列表...)

The HTTP 500 is coming from something else. HTTP 500来自其他内容。

I added exactly what you did in a new empty WebSite and the result is as expected. 我恰好在新的空WebSite中添加了您所做的操作,结果与预期的一样。

URL to test: http://jsonp.azurewebsites.net/demo.json 要测试的网址: http : //jsonp.azurewebsites.net/demo.json

Here is a fiddler trace from the request: 这是来自请求的提琴手跟踪:

GET http://jsonp.azurewebsites.net/demo.json HTTP/1.1
User-Agent: Fiddler
Host: jsonp.azurewebsites.net

And the response is also as expected: 响应也与预期的一样:

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}

I suggest that you turn on all the possible logging and examine the error logs. 我建议您打开所有可能的日志记录并检查错误日志。 Most probably you define system.webServer twice, or something similar. 您很可能两次定义了system.webServer或类似的东西。 Check out this SO question on how to enable logging. 查看有关如何启用日志记录的SO问题

UPDATE 更新

After updating the question it is apparent that cars.json is not real static file. 更新问题后,很明显cars.json不是真正的static文件。 So the question is a bit messed. 所以问题有点混乱。 What type of script are you executing inside this "file" ? 您在此“文件”中执行哪种类型的脚本?

UPDATE 2 更新2

Here is your json: http://jsonp.azurewebsites.net/demo.json 这是您的json: http//jsonp.azurewebsites.net/demo.json

Apparently you are having issue with rest of the website setup. 显然您在其余的网站设置上遇到了问题。 As I said - turn on all the logging and check the real error messages. 如我所说-打开所有日志记录并检查真正的错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM