Asp.net mvc Html.BeginForm不再在OrchardCMS中创建操作

Asp.net mvc Html.BeginForm不再在OrchardCMS中创建操作,asp.net-mvc,orchardcms,orchard-modules,Asp.net Mvc,Orchardcms,Orchard Modules,我最近为Orchard CMS项目重建了一个模块DLL,其中一个页面不再使用BeginFormAntiForgeryPost呈现表单操作 .cshtml文件是: @使用制度; @使用Orchard.Mvc.Html @{ var eventId = (int) Model.EventId; string price = (string)Model.Price; Orchard.ContentManagement.ContentItem contentItem = Mode

我最近为Orchard CMS项目重建了一个模块DLL,其中一个页面不再使用BeginFormAntiForgeryPost呈现表单操作

.cshtml文件是: @使用制度; @使用Orchard.Mvc.Html

@{
    var eventId = (int) Model.EventId;
    string price = (string)Model.Price;
    Orchard.ContentManagement.ContentItem contentItem = Model.Item;

    string currencies = (string)Model.Currencies;

    var pricesArray = price.Split(new Char[]{';'});
    var currenciesArray = currencies.Split(new Char[]{';'});

    bool allowCurrencyChange = true;

    if(pricesArray.Length!=currenciesArray.Length){
        allowCurrencyChange = false;
    }

    price = pricesArray[0];
    string currency = currenciesArray[0];

}

<div class="prices-container">
    <div class="more-info-link">
        <a class="btn" href="@Url.Content("~"+Url.ItemDisplayUrl(contentItem))">
            More Information
        </a>
    </div>
    <div class="prices-box">
        @if(Convert.ToDecimal(price)>0){
        <p class="price">@currency @String.Format("{0:0,0.00}",price) <br /><span style="font-size:13px;">+ VAT</span></p>
        }
        else{
        <p class="price" style="text-indent:-99999px;">@currency @String.Format("{0:0,0.00}",price)</p>
        }

        @using (Html.BeginFormAntiForgeryPost(Url.Action("Add", "ShoppingCart", new { id = eventId, area = "Events" }))) {

            if(Convert.ToDecimal(price)>0){
                <input type="hidden" name="currency" value="@currency" />
                <input type="hidden" name="price" value="@price" />

                if(allowCurrencyChange){
                    for(int i=0; i<pricesArray.Length;i++){
                        <input type="hidden" name="@(currenciesArray[i])_price" value="@(pricesArray[i])" />
                    }
                }

                <button class="btn btn-success" type="submit">@T("register")</button>
            }
            else{
                <a href="/oforms/Contact-Us" class="btn btn-success" >@T("enquire")</a>
            }
        }
    </div>
</div>
重建前的输出为:

<div class="prices-container" shape-id="13">
    <div class="more-info-link" shape-id="13">
        <a class="btn" href="/identify-the-right-talent" shape-id="13">
            More Information
        </a>
    </div>
    <div class="prices-box" shape-id="13">
        <p class="price" shape-id="13">GBP 1197.50 <br shape-id="13"><span style="font-size:13px;" shape-id="13">+ VAT</span></p>

        <form action="/Events/ShoppingCart/Add/13817" method="post" shape-id="13">              <input type="hidden" name="currency" value="GBP" shape-id="13">
            <input type="hidden" name="price" value="1197.50" shape-id="13">
            <input type="hidden" name="GBP_price" value="1197.50" shape-id="13">
            <button class="btn btn-success" type="submit" shape-id="13">register</button>
            <input name="__RequestVerificationToken" type="hidden" value="w10QfGWfU3Y2UNIWRVXtsqUxcSS/OX4GxWCAsdaWDMHV15LqkMpDcqQFYJ1lpbf7ZlNTP5ckVrWFtatRh2poJBTE9NxlXQRua8CNuXgVGtGnSr3lpWpt2KeAwNNhsvmZIiSSSZOuhwbXD08K7+H2fSkrFUAOKVX+eTarLBWdjg8jySGV+Q82oA37NMEBZrQXOWkq4TjEusC5ILqptA1fLZOR8qu0xuPlWrMf4Dli2kw=" shape-id="13">
        </form>    
    </div>
</div>
重建模块后,表单操作不再输出:

<div class="prices-container" shape-id="13">
    <div class="more-info-link" shape-id="13">
        <a class="btn" href="/identify-the-right-talent" shape-id="13">
            More Information
        </a>
    </div>
    <div class="prices-box" shape-id="13">
        <p class="price" shape-id="13">GBP 1197.50 <br shape-id="13"><span style="font-size:13px;" shape-id="13">+ VAT</span></p>

        <form action="" method="post" shape-id="13">                
            <input type="hidden" name="currency" value="GBP" shape-id="13">
            <input type="hidden" name="price" value="1197.50" shape-id="13">
            <input type="hidden" name="GBP_price" value="1197.50" shape-id="13">
            <button class="btn btn-success" type="submit" shape-id="13">register</button>
            <input name="__RequestVerificationToken" type="hidden" value="LcZyoXchQ7IjEJJvxoFQzAYNVOk1ybC7KB/GzXkYdlE5n1zIy6fg3Dod8twQDLxA/cYvBwYfXYDWbNSq81dsq4UTSxevK1vXJxWGAWKOlt0dmt3si5RKYJbIXEplIScSoEBtr5Jaq95YsCe4jpdMe3QroYF5NGj9P8BhPKWbucHJiLyBJULc6ktYuRL0BFQk+oE9AaaYUUv6hyh20T/XTlPjl9uxalvJMTCIiDtSlZQ=" shape-id="13">
        </form>    
    </div>
</div>

为什么BeginInformantiForgeryPost和/或Url.Action不再输出操作Url?

我认为它不会呈现操作如果MVC找不到指定的Url,请尝试检查该输出OK。所以路由可能出错了。。。谢谢我检查了一下。几天后,我将它加载到VS2010中,使它正常工作。显然,在VS2013中迁移它完全打乱了路由。我还不知道为什么,但它在VS2010中运行良好。