代码之家  ›  专栏  ›  技术社区  ›  spender

防止应用程序事件日志中出现ASP.NET MVC2异常

  •  1
  • spender  · 技术社区  · 14 年前

    自从升级到ASP.NET MVC2之后,我们注意到Windows应用程序事件日志中充满了以下条目:

    Event code: 3005 
    Event message: An unhandled exception has occurred. 
    Event time: 11/4/2010 3:29:16 PM 
    Event time (UTC): 11/4/2010 7:29:16 PM 
    Event ID: 2039870297302976340236
    Event sequence: 6422
    Event occurrence: 864 
    Event detail code: 0 
    
    ...
    Exception information: 
    Exception type: ArgumentException 
    Exception message: The parameters dictionary contains a null entry for parameter 'someParam' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(System.String, Int32)' in 'SomeNameSpace.SomeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
    

    请求不正确,因此出现此错误。很好,但是我希望在我的应用程序中处理这个问题,而不是允许它冒泡出事件日志。有什么建议吗?

    编辑

    看看答案 this question ,设置是否更合理? Route Constraints 处理这个问题?

    1 回复  |  直到 14 年前
        1
  •  1
  •   Darin Dimitrov    14 年前

    Application_Error [HandleError]