如果将null参数传递给action方法,则不会引发异常

时间:2012-05-20 21:53:10

标签: asp.net asp.net-mvc-3

我有以下行动方法: -

public PartialViewResult showpatientlabtests(int LabTest, int PatientID)
{   
    var vlr = repository.showpatientlabtests(LabTest, PatientID)
        .OrderByDescending(d => d.DateTaken);
    return PartialView("_showpatientlabtests", vlr); 
}

使用以下Ajax.Actionlink调用:

@using (Ajax.BeginForm("showpatientlabtests", "Patient", 
new AjaxOptions
{
    HttpMethod = "GET",
    InsertionMode = InsertionMode.Replace,
    UpdateTargetId = "searcharea",
    LoadingElementId = "progress",
    OnSuccess = "reenable"
}))
{
   <table>
     <tr>
       <th>
          Avilable LabTests
       </th>
       <th>
          @Html.DropDownList("LabTest", String.Empty)
          @Html.HiddenFor(model => model.PatientID)
       </th>
     </tr>
     <tr>
       <th>
         <input type="submit" value="Search      " />
       </th>
       <th>
       </th>
     </tr>

但是如果我将LabTest下拉列表留空,那么虽然我的action方法需要两个类型为ID的参数,但不会引发任何异常。我已经注意到ajax调用甚至不会达到预期的动作方法.....所以实际发生了什么?

0 个答案:

没有答案