【问题标题】:ASP.NET Windows authentication routing passing user id query stringASP.NET Windows 身份验证路由传递用户 ID 查询字符串
【发布时间】:2019-06-08 14:51:17
【问题描述】:

网址将是http://localhost:54088/UserAdmin/FindUser?UserId=COMPANY%5Ckarimf “/”应用程序中的服务器错误。 无法找到该资源。 说明:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。

请求的 URL:/UserAdmin/FindUser

控制器

public ActionResult FindUser(string UserId)
        {
            User user = db.Users.Find(UserId);
            return View(user);
        }

查看

 @if (Request.IsAuthenticated && User.IsInRole("Edit-Content")) {
            @Html.ActionLink("Edit", "FindUser", "UserAdmin",
              new { UserId = item.UserId }, new { @class = "btn btn-primary" })} |
            @if (Request.IsAuthenticated && User.IsInRole("Delete-Content"))
            {
                @Html.ActionLink("Delete", "Delete", "UsersAdmin",
                     new { UserId = item.UserId }, new { @class = "btn btn-danger" }) 
            }

【问题讨论】:

  • 前几天遇到了类似的问题,我很确定它与身份验证无关。它与您的控制器或 URL 有关,请考虑检查主机属性
  • 我知道控制器路由的问题,我有相同的搜索功能,但我不知道编辑用户有什么问题! @QuestGamer7

标签: c# sql-server asp.net-mvc asp.net-web-api url-routing


【解决方案1】:

我解决了.. UserAdmin 中缺少控制器名称 s

【讨论】:

  • 你能说出“s”到底是在哪里丢失的吗? :)
猜你喜欢
  • 1970-01-01
  • 2010-12-08
  • 1970-01-01
  • 2013-02-22
  • 1970-01-01
  • 2011-10-20
  • 1970-01-01
  • 1970-01-01
  • 2014-07-15
相关资源
最近更新 更多