我的應用程序在asp.net mvc中遇到問題。 在我的應用程序中,我使用FullCalendar jQuery whith請求的JSON數組中的事件。 jQueryCalendar如下所示。NetworkError:500當在主機上請求JSON時發生內部服務器錯誤
function renderCalendar() {
$("#cal").fullCalendar({
header: {
left: 'prev, next today',
center: 'title',
right: 'agendaDay, month'
},
height: 'auto',
fixedWeekCount: false,
firstDay: 1,
editable: false,
allDaySlot: false,
selectable: true,
slotMinutes: 15,
axisFormat: 'HH:mm',
eventLimit: true,
businessHours: {
start: '07:00',
end: '23:00'
},
eventLimitClick: 'day',
views: {
month: {
eventLimit: 8
}
},
lang: 'pl',
displayEventEnd: true,
timeFormat: {
month: "HH:mm"
},
events: {
url: '/Schedules/GetEvents/',
type: 'GET',
data: {
department_term: current_department,
}
},
dayClick: function (date, jsEvent, view) {
$('#cal')
.fullCalendar('changeView', 'agendaDay');
$('#cal')
.fullCalendar('gotoDate', date.format());
}
});
我的控制器動作看起來象下面這樣:
public JsonResult GetEvents(DateTime start, DateTime end, string department_term)
{
operations to generating listOfEvents
var results = listOfEvents.ToArray();
return Json(results, JsonRequestBehavior.AllowGet);
}
一切正常,在我的視覺本地主機上。但我必須將應用程序部署到somme.com,現在如果我打開日曆,則會出現NetworkError:500內部服務器錯誤(在firefox中觀看firebug)。我在firebug中發現答案的標題有一個Content-Type文本/ html; charset = utf-8而不是 Content-Type application/json; charset = utf-8 - 就像本地主機一樣。 它可能是什麼?
請幫幫我。
http://staff-net.somee.com/Schedules/Calendar
要melaspelas 我加入到我的配置代碼,就像你說的。就是這個。
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
但是,這仍然是行不通的。
我仍然有我的回答標題:
Content-Length 75
Content-Type text/html
Date Fri, 15 May 2015 10:45:26 GMT
Server Microsoft-IIS/8.5
,並請求頭:
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language pl,en-US;q=0.7,en;q=0.3
Content-Type application/json; charset=utf-8
Cookie b=b; ... <lot of text>
Host staff-net.somee.com
Referer http://staff-net.somee.com/Schedules/Calendar
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
X-Requested-With XMLHttpRequest
要peinearydevelopment: 您的參數不改變任何東西。
在Visual Studio的本地主機,我有:
在我的答案標題:
Cache-Control private, s-maxage=0
Content-Length 15263
Content-Type application/json; charset=utf-8
Date Fri, 15 May 2015 15:16:56 GMT
Server Microsoft-IIS/8.0
X-AspNet-Version 4.0.30319
X-AspNetMvc-Version 5.0
X-Powered-By ASP.NET
X-SourceFiles =?UTF-8?B?QzpcVXNlcnNcbGtvemxvd3NraVxEb2N1bWVudHNcVmlzdWFsIFN0dWRpbyAyMDEzXFByb2plY3RzXFNUQUZGLk5FVFxTVEFGRi5ORVRcU2NoZWR1bGVzXEdldEV2ZW50c1w
=?=
,並在請求頭:
Accept application/json, text/javascript, */*; q=0.01
Accept-Encodingg zip, deflate
Accept-Language pl,en-US;q=0.7,en;q=0.3
Cookie __RequestVerificationToken=LI...
Host localhost:50206
Referer http://localhost:50206/Schedules/Calendar
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
X-Requested-With XMLHttpRequest
而上託管我有:
回答頭
Cache-Control private, s-maxage=0
Content-Length 2903
Content-Type text/html; charset=utf-8
Date Fri, 15 May 2015 15:27:00 GMT
Server Microsoft-IIS/8.5
X-AspNet-Version 4.0.30319
X-AspNetMvc-Version 5.0
X-Frame-Options SAMEORIGIN
X-Powered-By ASP.NET
請求頭:
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language pl,en-US;q=0.7,en;q=0.3
Cookie b=b; b=b; questVerificationToke...
Host staff-net.somee.com
Referer http://staff-net.somee.com/Schedules/Calendar
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0
X-Requested-With XMLHttpRequest
你檢查你的IIS中的MIME類型? – dobleUber
謝謝你的回答。我從鏈接中讀取信息,但我的應用程序部署在主機上,並且我無法訪問服務器的配置。有其他解決方法嗎?例如在我的應用程序的本地Web.config? –
我更新了我的答案與web.config設置 – dobleUber