Submit Product Review The required anti-forgery form field "__RequestVerificationToken" is not present.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
kh_s wrote:
i change to this but give error again :(
@model ProductReviewsModel
@using Nop.Web.Models.Catalog;
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken();
}
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(Model.ProductName);
.
.
.



Replace  the file with following and try==?

@model ProductReviewsModel
@using Nop.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_ColumnsOne.cshtml";

    //title
    Html.AddTitleParts(Model.ProductName);
    Html.AddTitleParts(T("PageTitle.ProductReviews").Text);
}
<div class="page product-reviews-page">
    <div class="page-title">
        <h1>@T("Reviews.ProductReviewsFor") <a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })">@Model.ProductName</a></h1>
    </div>
    <div class="page-body">
        @Html.Widget("productreviews_page_top", Model.ProductId)
        @if (Model.AddProductReview.SuccessfullyAdded)
        {
            <div class="result">
                @Model.AddProductReview.Result
            </div>
        }
        else
        {
            <div class="write-review" id="review-form">
                <div class="title">
                    <strong>@T("Reviews.Write")</strong>
                </div>
                @using (Html.BeginForm())
                {
                    @Html.AntiForgeryToken()
                    var validationSummary = Html.ValidationSummary(true);
                    if (!MvcHtmlString.IsNullOrEmpty(validationSummary))
                    {
                        <div class="message-error">@validationSummary</div>
                    }
                    <div class="fieldset">
                        <div class="form-fields">
                            <div class="inputs">
                                @Html.LabelFor(model => model.AddProductReview.Title, new { }, ":")
                                @Html.TextBoxFor(model => model.AddProductReview.Title, Model.AddProductReview.CanCurrentCustomerLeaveReview ? (object)(new { @class = "review-title" }) : (object)(new { @class = "review-title", disabled = "disabled" }))
                                @Html.RequiredHint()
                                @Html.ValidationMessageFor(model => model.AddProductReview.Title)
                            </div>
                            <div class="inputs">
                                @Html.LabelFor(model => model.AddProductReview.ReviewText, new { }, ":")
                                @Html.TextAreaFor(model => model.AddProductReview.ReviewText, Model.AddProductReview.CanCurrentCustomerLeaveReview ? (object)(new { @class = "review-text" }) : (object)(new { @class = "review-text", disabled = "disabled" }))
                                @Html.RequiredHint()
                                @Html.ValidationMessageFor(model => model.AddProductReview.ReviewText)
                            </div>
                            <div class="review-rating">
                                @Html.LabelFor(model => model.AddProductReview.Rating, new { }, ":")
                                <ul>
                                    <li class="label first">@T("Reviews.Fields.Rating.Bad")</li>
                                    <li class="rating-options">
                                        @Html.RadioButtonFor(model => model.AddProductReview.Rating, "1", new { id = "addproductrating_1" })
                                        @Html.RadioButtonFor(model => model.AddProductReview.Rating, "2", new { id = "addproductrating_2" })
                                        @Html.RadioButtonFor(model => model.AddProductReview.Rating, "3", new { id = "addproductrating_3" })
                                        @Html.RadioButtonFor(model => model.AddProductReview.Rating, "4", new { id = "addproductrating_4" })
                                        @Html.RadioButtonFor(model => model.AddProductReview.Rating, "5", new { id = "addproductrating_5" })
                                    </li>
                                    <li class="label last">@T("Reviews.Fields.Rating.Excellent")</li>
                                </ul>
                            </div>
                            @if (Model.AddProductReview.DisplayCaptcha)
                            {
                                <div class="captcha-box">
                                    @Html.Raw(Html.GenerateCaptcha())
                                </div>
                            }
                        </div>
                    </div>
                    <div class="buttons">
                        <input type="submit" name="add-review" class="button-1 write-product-review-button" value="@T("Reviews.SubmitButton")" />
                    </div>
                }
            </div>
        }
        @if (Model.Items.Count > 0)
        {
            <div class="product-review-list">
                <div class="title">
                    <strong>@T("Reviews.ExistingReviews")</strong>
                </div>
                @foreach (var review in Model.Items)
                {
                    int ratingPercent = review.Rating * 20;
                    <div class="product-review-item">
                        <div class="review-item-head">
                            <div class="review-title">
                                <strong>@review.Title</strong>
                            </div>
                            <div class="product-review-box">
                                <div class="rating">
                                    <div style="width: @(ratingPercent)%">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="review-content">
                            <div class="review-text">
                                @Html.Raw(Nop.Core.Html.HtmlHelper.FormatText(review.ReviewText, false, true, false, false, false, false))
                            </div>
                            <div class="review-info">
                                <span class="user">
                                    <label>@T("Reviews.From"):</label>
                                    @if (review.AllowViewingProfiles)
                                    {
                                        <a href="@Url.RouteUrl("CustomerProfile", new { id = review.CustomerId })">@(review.CustomerName)</a>
                                    }
                                    else
                                    {
                                        @review.CustomerName
                                    }
                                </span>
                                <span class="separator">|</span>
                                <span class="date">
                                    <label>@T("Reviews.Date"):</label>
                                    <span>@review.WrittenOnStr</span>
                                </span>
                            </div>
                            @Html.Partial("_ProductReviewHelpfulness", review.Helpfulness, new ViewDataDictionary())
                            @Html.Widget("productreviews_page_inside_review", review.Id)
                        </div>
                    </div>
                }
            </div>
        }
        @Html.Widget("productreviews_page_bottom", Model.ProductId)
    </div>
</div>

8 years ago
thanks sohel, solved <3
7 years ago
sohel wrote:
Write the following code in ProductReviews.cshtml into the form tag
 @Html.AntiForgeryToken()


thanks for sharing this useful answer, this has solved our issue, and we wish to update this in the downloadable them for new users.
We really appreciate your support in this regard, and wish you the best.

:)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.