C# 带有HTTPStatusCodeResult的自定义错误消息&;jQuery
我有一个控制器操作,它将一些JSON结果返回给jQuery完整日历插件。如果出现错误,我将返回带有自定义错误消息的C# 带有HTTPStatusCodeResult的自定义错误消息&;jQuery,c#,jquery,.net,asp.net-mvc-3,http,C#,Jquery,.net,Asp.net Mvc 3,Http,我有一个控制器操作,它将一些JSON结果返回给jQuery完整日历插件。如果出现错误,我将返回带有自定义错误消息的httpstatuscodesult,但无法显示自定义错误消息。警报框中显示的只是默认Http状态(即:“禁止”或“内部服务器错误”) 返回错误消息的控制器代码 else if(id != CurrentUser.UserId) { return new HttpStatusCodeResult(403, "You are not authorised to view thi
httpstatuscodesult
,但无法显示自定义错误消息。警报框中显示的只是默认Http状态(即:“禁止”或“内部服务器错误”)
返回错误消息的控制器代码
else if(id != CurrentUser.UserId)
{
return new HttpStatusCodeResult(403, "You are not authorised to view this.");
}
else
{
return new HttpStatusCodeResult(500, "There was an error on the server.");
}
jQuery代码
$(document).ready(function () {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
height: 600,
eventSources: [{
url: events,
type: 'Get',
error: function(response, status, error) {
alert(response.statusText);
}
}],
allDayDefault: false,
selectable: true,
eventClick: function (event) {
if (event.url) {
$('#details').load(event.url);
}
},
实际上,代码中根本没有任何问题。问题在于Visual Studio中的ASP.NET开发Web服务器。我改用IIS express,效果很好。我不知道为什么微软还没有解决这个问题。我今天花了一个多小时试图看看我做错了什么。我想知道这些天有多少工程师在VS Web开发服务器上工作?我猜是0