如果未传递参数变量,则此代码抛出“从字符串转换”“到”类型'日期'无效的异常。“
这是我的代码。
Public Shared ReadOnly Property Request_projectStartDate() As Date
Get
Dim _value As String = Nothing
If Not HttpContext.Current.Request.QueryString("projectStartDate") Is Nothing Then
_value = HttpContext.Current.Request.QueryString("projectStartDate").ToString()
End If
Return CDate(_value)
End Get
End Property
答案 0 :(得分:12)
您可以查看@Massimiliano报告的内容以及另外一项检查
If Request.QueryString.HasKeys() Then
// Check for specified querystrings...
If Not String.IsNullOrEmpty(Request.QueryString("projectStartDate")) Then
// Your logic
End If
End If
答案 1 :(得分:1)
If Not String.IsNullOrEmpty(Request.QueryString("projectStartDate")) Then
//
End If
答案 2 :(得分:0)
如果Request.QueryString(" projectStartDate")IsNot Nothing和Request.QueryString(" projectStartDate")<> ""然后