【问题标题】:The name does not exist in the current context. Shopping cart当前上下文中不存在该名称。购物车
【发布时间】:2017-01-31 12:48:51
【问题描述】:

我正在按照将 PayPal 集成到 MVC 4 中的指南进行操作。但是,我遇到了这个错误“当前上下文中不存在名称“会话”。” & "名称“响应”在当前上下文中不存在。"

https://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/checkout-and-payment-with-paypal

protected void CheckoutBtn_Click(object sender, ImageClickEventArgs e)
    {
        using (ShoppingCart usersShoppingCart = new ShoppingCart())
        {
            Session["payment_amt"] = usersShoppingCart.GetTotal();
        }
        Response.Redirect("Checkout/CheckoutStart.aspx");
    }
}

我已在链接到结帐页面的模型中输入了上述代码。 请赐教谢谢。我是 MVC 新手。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 paypal model


    【解决方案1】:

    听起来您缺少 System.Web 命名空间。将它包含在您班级的顶部,例如so。如果您随后收到“找不到命名空间”的错误,那么您缺少对 System.Web 的引用。

    【讨论】:

    • 我的项目中有“使用 system.web”和 system.web 参考。我也为 ImageClickEventArgs 在模型中添加了“使用 system.web.ui”。感谢您的回复。
    猜你喜欢
    • 2012-09-12
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多