Ошибка HTTP 400.0 - неверный запрос ASP.NET MVC - PullRequest
0 голосов
/ 30 августа 2018

Aftrer Я создаю частичный вид для редактирования / деталей и значка удаления, у меня проблема с этим типом ошибки

HTTP Error 400.0 - Bad Request
Bad Request

Я все проверяю и не могу найти, где я допустил ошибку.

SmallButtonModel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Memberships.Areas.Admin.Models
{
    public class SmallButtonModel
    {
        public string Action { get; set; }

        public string Text { get; set; }

        public string Glyph { get; set; }

        public string ButtonType { get; set; }

        public int? Id { get; set; }

        public int? ItemId { get; set; }

        public int? ProductId { get; set; }

        public int? SubscriptionId { get; set; }

        public string ActionParameters
        {
            get
            {
                var param = new StringBuilder("?");
                if (Id != null && Id > 0)
                    param.Append(String.Format("{0} = {1}&", "id", Id));

                if (ItemId != null && ItemId > 0)
                    param.Append(String.Format("{0} = {1}&", "itemId", ItemId));

                if (ProductId != null && ProductId > 0)
                    param.Append(String.Format("{0} = {1}&", "productId", ProductId));

                if (SubscriptionId != null && SubscriptionId > 0)
                    param.Append(String.Format("{0} = {1}&", "subscriptionId", SubscriptionId));

                return param.ToString().Substring(0, param.Length - 1);
            }
        }
    }
}

_TablePartialView.cshtml

@model Memberships.Areas.Admin.Models.SmallButtonModel
@using Memberships.Areas.Admin.Models;

<td style="width:120px;">
    <div class="btn-group" role="group">
        @Html.Partial("_SmallButtonPartial",
    new SmallButtonModel
    {
        Action = "Edit",
        ButtonType = "btn-primary",
        Glyph = "pencil",
        Text = "Edit button",
        Id = Model.Id,
        ItemId = Model.ItemId,
        ProductId = Model.ProductId,
        SubscriptionId = Model.SubscriptionId

    })

        @Html.Partial("_SmallButtonPartial",
            new SmallButtonModel
            {
                Action = "Details",
                ButtonType = "btn-success",
                Glyph = "list",
                Text = "Detail button",
                Id = Model.Id,
                ItemId = Model.ItemId,
                ProductId = Model.ProductId,
                SubscriptionId = Model.SubscriptionId

            })

           @Html.Partial("_SmallButtonPartial",
            new SmallButtonModel
            {
                Action = "Delete",
                ButtonType = "btn-danger",
                Glyph = "trash",
                Text = "Delete button",
                Id = Model.Id,
                ItemId = Model.ItemId,
                ProductId = Model.ProductId,
                SubscriptionId = Model.SubscriptionId

            })
    </div>
</td>

Index.cshtml

@model IEnumerable<Memberships.Entities.Item>

@using Memberships.Areas.Admin.Models;

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.Partial("_CreateButtonPartia")
</p>
<table class="table table-striped table-condensed">
    <tr class="success">
        <th>
            @Html.DisplayNameFor(model => model.Title)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Description)
        </th>

        <th>
            @Html.DisplayNameFor(model => model.HTML)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.WaitDays)
        </th>       
        <th>
            @Html.DisplayNameFor(model => model.IsFree)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>       
        <td>
            @Html.DisplayFor(modelItem => item.HTML)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.WaitDays)
        </td>

        <td>
            @Html.DisplayFor(modelItem => item.IsFree)
        </td>

         @Html.Partial("_TableButtonsPartial",
         new SmallButtonModel { Id = item.Id })
    </tr>
}

</table>

После добавления _TablePartialButton в Index.cshtml я получаю сообщение об ошибке, но когда я восстанавливаю метод HTML.ActionResult () по умолчанию, он работает нормально Любое предложение, комментарий?

1 Ответ

0 голосов
/ 31 августа 2018

Проверьте правильность написания имени вашего контроллера и просмотра имени. 404 ошибка ресурса не найдена.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...