未找到路径'/ Account / Login'的控制器或未实现IController(The controller for path '/Account/Login&#

编程入门 行业动态 更新时间:2024-10-27 18:20:59
未找到路径'/ Account / Login'的控制器或未实现IController(The controller for path '/Account/Login' was not found or does not implement IController)

..但我没有登录控制器!

我在抛出自定义错误时得到它。

我的意思是..是的。 我从一个有一个的示例项目开始我的项目,我删除了帐户控制器,它的视图,甚至任何引用“登录”的代码(甚至web.config中可能提到它的任何条目)和它出现了这个错误。

我还能在哪里检查?

更新:我使用的是Active Directory而不是登录表单。

..but I don't have a Login Controller!

I get it when I throw a custom error.

I mean.. yeah. I started my project from a sample project that had one, and I deleted the Account Controller, its view, and even any code that referred to "Login", (and even any entries in the web.config that may mention it) and it comes up with this error.

where else would I check?

Update: I am using Active Directory instead of a login form.

最满意答案

只需将这些行添加到您的Web配置文件中:

<authentication mode="Forms"> <forms loginUrl="~/home/Login" timeout="2880"></forms> </authentication>

在loginUrl中输入正确的登录页面目的地,它将重定向所有标记为[授权]的请求,而不是帐户/登录。

ok. so it seems like my issue was with the fact that I am using custom [Authorize] attributes, and I didn't have a login page at all. I am using Active Directory.

According to @Lars & @Shani, apparently I need to somehow point back to one.

Unfortunately I can't as I don't have one, and it would be useless to create one. So I came up with a method that works with my situation. In my custom [Authorize] attribute, I'm returning a RedirectToRouteResult that goes to my custom Error page:

protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext) { base.HandleUnauthorizedRequest(filterContext); if (!_authorized) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "ErrorPage", action = "Unauthorized" })); } }

I'm sure there is a few different ways to do this, but this is what I'm going with this at the moment..

更多推荐

本文发布于:2023-08-05 03:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1427298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   路径   未找到   或未   Account

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!