I'm trying to you a web service wi开发者_高级运维th my MVC3 controller. This service has an optional parameter, such as
Service.GetObject(int id, DateTime? date)
But when I try to call it will a null value , like
Service.GetObject(id, null)
I get this error.
$exception {"Object cannot be cast from DBNull to other types."} System.Exception {System.ServiceModel.FaultException}
Please help if you can.
It looks like the service is trying to cast from DBNull to some other type (DBNull != null) and since the code you show has no notion of DBNull it's hard to say what the problem is but it doesn't look like it's in the client code
You should't have to even use null for the second parameter in your call.
http://blogs.msdn.com/b/simonince/archive/2011/02/02/asp-net-mvc-3-optional-parameter-routing-issue.aspx
精彩评论