Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';System.Web.Mvc.HtmlHelper';没有名为'的适用方法;部分';_C#_Asp.net Mvc 3_Debugging - Fatal编程技术网

C# ';System.Web.Mvc.HtmlHelper';没有名为'的适用方法;部分';

C# ';System.Web.Mvc.HtmlHelper';没有名为'的适用方法;部分';,c#,asp.net-mvc-3,debugging,C#,Asp.net Mvc 3,Debugging,我得到这个错误: 错误CS1973:“System.Web.Mvc.HtmlHelper”没有适用的 名为“Partial”的方法,但似乎具有该方法的扩展方法 名称无法动态调度扩展方法。考虑 强制转换动态参数或调用扩展方法而不使用 扩展方法语法。“} 从我在这里读到的是,这是由于使用viewbag(?),我真正使用的是会话 这是我的网络表单: @using SuburbanCustPortal.MiscClasses @{ ViewBag.Title = "Account Screen

我得到这个错误:

错误CS1973:“System.Web.Mvc.HtmlHelper”没有适用的 名为“Partial”的方法,但似乎具有该方法的扩展方法 名称无法动态调度扩展方法。考虑 强制转换动态参数或调用扩展方法而不使用 扩展方法语法。“}

从我在这里读到的是,这是由于使用viewbag(?),我真正使用的是会话

这是我的网络表单:

@using SuburbanCustPortal.MiscClasses

@{
    ViewBag.Title = "Account Screen";
 }

<h2>AccountScreen</h2>

<div class="leftdiv">
  <fieldset>
    <legend>Customer Info</legend>
    @Html.Partial("CustomerInfo")
  </fieldset>

  <fieldset>
    <legend>Delivery Address</legend>
    @Html.Partial("DeliveryAddress")
  </fieldset>

  <fieldset>
    <legend>Delivery Info</legend>
    @Html.Partial("DeliveryInfo")
  </fieldset>
</div>

<div class="rightdiv">
  <fieldset> 
    <legend>Balance</legend>
      @Html.Partial("AccountBalance")
  </fieldset>

             @if (SessionHelper.ShowPaymentOptions || SessionHelper.ShowHistory)
             {
               <fieldset>
                 <legend>Account Options</legend>
                 <br/>

                 @using (Html.BeginForm("AccountScreenButton", "Customer", FormMethod.Post))
                 {
                   <div class="sidebysidebuttons">
                     <div class="box">
                       @if (SessionHelper.ShowHistory && SessionHelper.ShowAccountScreenPaymentButton)
                       {
                         <button class="sidebysidebutton1" name="options" value="payment">Make a Payment</button>
                         <button class="sidebysidebutton2" name="options" value="activity">Display Activity</button>
                       }
                       else
                       {
                         if (SessionHelper.ShowAccountScreenPaymentButton)
                         {
                           <button class="leftpaddedsinglebutton" name="options" value="payment">Make a Payment</button>
                         }

                         if (SessionHelper.ShowHistory)
                         {
                           <button class="leftpaddedsinglebutton" name="options" value="activity">Display Activity</button>
                         }
                       }
                     </div>
                   </div>
                 }    
               </fieldset>
             }

  <fieldset> 
      <legend>Billing Info</legend>
        @Html.Partial("BillingInfo", Model)
    </fieldset>
</div>
我不确定问题是否存在于表单中,因为当我在表单中设置断点时,它并没有停止

我有两个问题:

  • 如何调试表单上的问题所在位置
  • 我可以不使用类作为会话并在表单中引用它吗?我假设这就是问题所在

  • 您的问题是没有在视图顶部定义模型。因此,默认类型为
    dynamic

    通常,这不是问题,但您有以下问题:

    @Html.Partial("BillingInfo", Model)
    
    实际上,这是将动态类型传递给
    Html.Partial()
    ,这就是引发错误的原因


    不管怎么说,这是一个毫无意义的调用,只需删除其中的模型部分,它就会工作。不管怎么说,传递模型是默认操作,因此您不会尝试做任何不是默认操作的事情。

    Ha…我甚至没有注意到。Ty!关于在mvc中调试web表单的任何想法?@ErocM-您需要直接在对象上设置光标您要调试,然后点击F9。例如,如果您要调试这种情况,请将光标放在.Partial部分,然后按F9。如果不这样做,它将无法获得正确的上下文。类似的问题,但只是尝试从动态对象传递字符串。只需先转换为字符串。
    @Html.Partial("BillingInfo", Model)