【发布时间】:2015-04-12 11:01:29
【问题描述】:
我收到此错误:
错误 CS1973:“System.Web.Mvc.HtmlHelper”不适用 名为“部分”的方法,但似乎有一个扩展方法 姓名。扩展方法不能动态调度。考虑 强制转换动态参数或调用扩展方法 扩展方法语法。"}
从我在这里读到的Razor View Engine : An expression tree may not contain a dynamic operation 是由于使用了我真正使用 Session 的 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>
这是我的 SessionHelper 的一部分,给你一个想法:
public static CustomerData CustomerSessionData
{
get
{
try
{
return (CustomerData) HttpContext.Current.Session["CustomerSessionData"];
}
catch (Exception)
{
return null;
}
}
set { HttpContext.Current.Session["CustomerSessionData"] = value; }
}
public static bool ShowPaymentTab
{
get { return HttpContext.Current.Session["ShowPaymentTab"].ToBool(); }
set { HttpContext.Current.Session["ShowPaymentTab"] = value; }
}
我不确定问题是否出在表单中,因为当我在表单中设置断点时,它并没有就此停止。
我有两个问题:
- 如何调试表单上的问题所在?
- 能否不将类用作会话并在表单中引用它?我假设这就是问题所在。
【问题讨论】:
标签: c# asp.net-mvc-3 debugging