English 中文(简体)
处理MVC申请中无法使用的数据库的设想
原标题:Handling a scenario of an unavailable database in an MVC application

在这种情形下,我也希望绕过我正常的错误记录,这种记录赢得了工作,只是要求埃尔傲慢的观点,发出电子邮件。 我不想重复所有控制人员处理这一特殊案件的做法,在要求采取任何行动之前,可能会试图让非行进入。 我应该把这名特别手提放在哪里,如果不是控制人,那么我如何看待错误观点?

Oh 是的,Im利用Elmah例行记录未经处理的例外情况。

最佳回答

贵方控制员使用这些内容

[HandleError(ExceptionType = typeof(SqlException), View = "SqlError")]
Public Class ProductController: Controller {
    public ViewResult Item(string itemID)
    {
            Item item = ItemRepository.GetItem(itemID);
            return View(item);
    }
}

现在,在您的<编码>意见/共享/中,你可以形成一种称为“SqlError.aspx”的观点,如果存在一种特殊的例外情况,该观点将予退回。

我也建议处理你在全球提出的所有申请。 页: 1 IE: The part that do the emailing of the有误、记录错误等。

Check out this SO question for an idea
ASP.NET MVC Custom Error Handling Application_Error Global.asax?

问题回答

我不知道你的代码是什么,但假设在某些全球错误处理事项中进行伐木,那么处理错误就象这样做一样:

try
{
  //logging
}
catch(SqlException)
{
  //send email
  return View("Error");
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签