简体   繁体   中英

Azure/WebMatrix web.config 500 Error

I've tried to add a MIME type to the webmatrix web.config file to run in 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.

The site works locally.

Is there something else in Azure I need to do?

(Edit:)

All I have in web.config is:

<?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.

Error in console:

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

UPDATE

The file doesn't change and is called by JavaScript from a Sencha Architect tutorial app.

{
"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

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.

It appears the Azure server is ignoring my web.config file with something else...

(I've enabled debugging in Azure but can't find a list of errors yet...)

The HTTP 500 is coming from something else.

I added exactly what you did in a new empty WebSite and the result is as expected.

URL to test: 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. Check out this SO question on how to enable logging.

UPDATE

After updating the question it is apparent that cars.json is not real static file. So the question is a bit messed. What type of script are you executing inside this "file" ?

UPDATE 2

Here is your 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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