websitepanel/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/ErrorController.cs
2015-01-13 04:18:56 -08:00

28 lines
No EOL
892 B
C#

using System;
using System.Web.Mvc;
using WebsitePanel.WebDav.Core.Config;
using WebsitePanel.WebDavPortal.Models;
namespace WebsitePanel.WebDavPortal.Controllers
{
public class ErrorController : Controller
{
public ActionResult Index(int statusCode, Exception exception, bool isAjaxRequet)
{
var model = new ErrorModel
{
HttpStatusCode = statusCode,
Message = WebDavAppConfigManager.Instance.HttpErrors[statusCode],
Exception = exception
};
Response.StatusCode = statusCode;
if (!isAjaxRequet)
return View(model);
var errorObject = new { statusCode = model.HttpStatusCode, message = model.Message };
return Json(errorObject, JsonRequestBehavior.AllowGet);
}
}
}