我正在尝试使用[HandleError]
.
我改变了网络配置<customErrors mode="On" />
它不适用于自定义错误,例如NotImplementedException
我已保存CustomErrorView
在共享文件夹中。
请帮忙....
namespace MvcApplicationErrorHandling.Controllers
{
[HandleError(Order = 2)]
[HandleError(ExceptionType = typeof(NotImplementedException), View = "CustomErrorView")]
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
public ActionResult About()
{
return View();
}
public ActionResult ThrowException()
{
throw new ApplicationException();
}
public ActionResult ErrorDemo()
{
string strtemp;
Object obj = null;
strtemp = obj.ToString();
return View();
}
public ActionResult ThrowNotImplemented()
{
throw new NotImplementedException();
}
}
}