找不到路径"/Account/Login"的控制器或未实现IController [英] The controller for path '/Account/Login' was not found or does not implement IController

查看:69
本文介绍了找不到路径"/Account/Login"的控制器或未实现IController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

当我抛出一个自定义错误时,我得到了它.

I get it when I throw a custom error.

我的意思是..是的.我从一个有一个示例项目开始了我的项目,然后删除了Account Controller,其视图,甚至所有引用"Login"的代码(甚至是web.config中可能提及它的所有条目)及其出现此错误.

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.

我还要去哪里检查?

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

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

推荐答案

好.因此看来我的问题在于我使用的是自定义 [Authorize] 属性,而我根本没有登录页面 .我正在使用Active Directory.

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.

根据@Lars&@Shani,显然我需要以某种方式回到原来的位置.

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

不幸的是,我不能,因为我没有一个,创建一个将毫无用处.因此,我想出了一种适合我的情况的方法.在我的自定义 [Authorize] 属性中,我返回的 RedirectToRouteResult 进入了我的自定义错误页面:

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..

这篇关于找不到路径"/Account/Login"的控制器或未实现IController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆