【发布时间】:2015-05-13 14:23:59
【问题描述】:
我在 asp.net mvc 中的应用程序有问题。 在我的应用程序中,我使用了在 JSON 数组中请求的 FullCalendar jQuery 事件。 jQueryCalendar 如下所示。
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 Internal Server Error(在 firefox 的 firebug 中观看)。我在萤火虫中发现答案的标题有一个 Content-Type text/html; charset=utf-8 而不是 内容类型应用程序/json; charset=utf-8 - 就像在本地主机上一样。 会是什么?
请帮帮我。
http://staff-net.somee.com/Schedules/Calendar
致梅拉斯佩拉斯 我像你说的那样添加到我的配置代码中。就是这样。
<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
到胚胎发育: 你的参数不会改变任何东西。
在 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/type 吗??
-
感谢您的回答。我从您的链接中读取了信息,但我的应用程序部署在主机上,我无法访问服务器的配置。还有其他方法可以解决吗?例如在我的应用程序的本地 Web.config 中?
-
我用 web.config 设置更新了我的答案
-
我用你的线索更新我的问题。那么没有配置IIS就没有办法修复它吗?那么这种情况下就没有解决办法了吗?
-
也许您遇到了真正的错误,您可以关闭 ASP.net 的自定义错误。
标签: jquery asp.net json asp.net-mvc iis