自从升级到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
处理这个问题?