Asp.net mvc 4 MVC 4-在'/';应用

Asp.net mvc 4 MVC 4-在'/';应用,asp.net-mvc-4,razor,Asp.net Mvc 4,Razor,我有以下错误,我找不到任何原因。我在正确的文件夹中也有视图 The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the followin

我有以下错误,我找不到任何原因。我在正确的文件夹中也有视图

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Account/GetUsers
我的控制器类代码如下:我正在尝试获取数据库中的用户列表并显示

 public class AccountController : Controller
    {

        [AllowAnonymous]
        [HttpPost]
        public ActionResult GetUsers()
        {
            var availableProfiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
// havent implement yet...
            return View();
        }
}
我的看法如下:

@model IEnumerable<LibraryManagementWeb.Models.StaffModel>

@{
    ViewBag.Title = "GetUsers";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="box">
            <div class="box-header" data-original-title="">
                <h2>
                    <i class="icon-user"></i>
                    <span class="break"></span>
                    Staff user Details
                </h2>
                <div class="box-icon">
                </div>
            </div>
            <div class="box-content">
                              <fieldset class="col-sm-12">
                            <legend></legend>      


                 <a href="@Url.Action("RegisterStaf", "Account")" class="btn btn-success"><i class="icon-zoom-in "></i> <span>Add</span></a>


</fieldset>                   

            </div>
        </div>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
这是什么原因呢

编辑:我的路线详细信息如下:

                @if (User.IsInRole("Admin"))
                {
                    <li><a href="@Url.Action("GetUsers", "Account")"><i class="icon-user"></i><span class="hidden-sm">User Management</span></a></li>
                }
public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }

我想我知道你的问题是什么。在此代码中:

public class AccountController : Controller
    {

        [AllowAnonymous]
        [HttpPost]
        public ActionResult GetUsers()
        {
            var availableProfiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
// havent implement yet...
            return View();
        }
}
请注意
[HttpPost]
属性。这导致该操作方法仅在通过
POST
提交页面时匹配-它不匹配
GET
请求。如果您没有相应的操作方法来接受
GET
请求,您将得到404错误


从您在该方法中所拥有的内容来看,您似乎根本不需要
[HttpPost]
。请尝试删除该属性,然后重试。

我们可以查看您的路线吗?@AndrewBarber我也用路线详细信息编辑了我的问题……谢谢。。这就是为什么。。。我删除了
[AllowAnonymous]
[HttpPost]
单词。。。那么它就可以正常工作了。。。。谢谢。。。。。