【问题标题】:MVC 5 with @Scripts.Render(“~/bundles/jquery”) Compilation Error带有@Scripts.Render(“~/bundles/jquery”) 的 MVC 5 编译错误
【发布时间】:2015-06-05 17:57:58
【问题描述】:

我正在开发一个具有 Payfast 实施的 MVC5 项目。我有一个视图,可以将所有信息提交到 Payfast 网站以进行付款。如果我运行该项目,它总是给我Compilation Error指向@Scripts.Render("~/bundles/jquery")。我很困惑,请帮忙。

这是给我带来问题的观点。

 @model Template.Model.PayFastModel

<body>
    <form id="hiddenform" action=@Model.actionURL>
        @Html.HiddenFor(model => model.merchant_id)
        @Html.HiddenFor(model => model.merchant_key)
        @Html.HiddenFor(model=>model.m_payment_id)
        @Html.HiddenFor(model=>model.payment_mode)
        @Html.HiddenFor(model => model.name_first)
        @Html.HiddenFor(model => model.name_last)
        @Html.HiddenFor(model => model.email_address)
        @Html.HiddenFor(model=>model.site)
        @Html.HiddenFor(model => model.@return)
        @Html.HiddenFor(model => model.cancel_return)
        @Html.HiddenFor(model => model.notify_url)
        @Html.HiddenFor(model => model.item_name)
        @Html.HiddenFor(model => model.amount)
    </form>

    <br/><br /><br /><br /><br /><br />
    <p style="text-align: center">
        <h3>
            Connecting to Payfast , please wait ...

        </h3>
    </p>
</body>
@Scripts.Render("~/bundles/jquery")

<script type="text/javascript" language="javascript">
    $(this.document).ready(function () {
        var form = $("form");
        form.submit();
    });
</script>

错误信息:

【问题讨论】:

  • 错误信息是什么?
  • 请向我们展示完整、准确的错误信息。
  • BundleConfig.cs 中的捆绑包设置是什么样的?
  • 我的项目中没有BundleConfig.cs。我必须有一个吗?如果我应该包含它,它应该是什么样子?

标签: jquery asp.net-mvc jquery-ui


【解决方案1】:

确保Views 文件夹中的web.config 中有以下行:

<system.web.webPages.razor>
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
      ...
      <!-- THIS LINE: -->
      <add namespace="System.Web.Optimization" />

此外,您可能还缺少对 System.Web.Optimization 程序集的引用,请确保它存在。

【讨论】:

  • 在已解决的web.config 中添加&lt;add namespace="System.Web.Optimization" /&gt; 对我有帮助。非常感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-10-16
  • 2021-09-01
  • 1970-01-01
  • 2013-05-25
  • 1970-01-01
  • 1970-01-01
  • 2021-09-26
相关资源
最近更新 更多