How do I pass a null value to an ASP.NET web service when accessing it via 开发者_如何学JAVAHTTP POST?
[WebMethod]
public string GetResult(DateTime date, int foo)
{
//do stuff here
}
When calling this method using HTTP POST, how do I pass a null parameter? Passing empty string just makes the server throw an exception trying to convert the string parameter to a DateTime. Making the DateTime parameter nullable (i.e. DateTime? date
) seems to disallow calling it via HTTP.
Neither of these can have null values. They are both value types and can't be set to null even if you attempted to do it using code. I would recommend sending DateTime.MinValue
and 0.
精彩评论