Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net MVC自定义身份验证?_Asp.net_Model View Controller - Fatal编程技术网

Asp.net MVC自定义身份验证?

Asp.net MVC自定义身份验证?,asp.net,model-view-controller,Asp.net,Model View Controller,我编写了一个使用自定义身份验证的小型mvc应用程序。除帐户控制器的登录操作外,应用程序中的所有操作都使用以下注释:[CustomAuthorize(Roles=“User”)] 这意味着每个页面都将被重定向到登录页面进行身份验证。除了一个小错误外,该应用程序工作正常。在应用程序属性页面中,我将启动操作设置为当前页面。当应用程序启动时,我希望应用程序将重定向到登录页面,但它返回以下错误: Server Error in '/' Application. The resource cannot be

我编写了一个使用自定义身份验证的小型mvc应用程序。除帐户控制器的登录操作外,应用程序中的所有操作都使用以下注释:
[CustomAuthorize(Roles=“User”)]
这意味着每个页面都将被重定向到登录页面进行身份验证。除了一个小错误外,该应用程序工作正常。在应用程序属性页面中,我将启动操作设置为当前页面。当应用程序启动时,我希望应用程序将重定向到登录页面,但它返回以下错误:

Server Error in '/' Application.
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: /

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
请帮忙!
谢谢。

检查您的路线配置文件

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

你的RouteConfig.cs怎么样?添加默认路由routes.MapRoute(名称:“默认”,url:{controller}/{action}/{id}”默认值:新建{controller=“Home”,action=“Index”,id=urlparmeter.Optional});好的。问题是我删除了HomeController,但我没有修改默认路由的RouteConfig.cs。现在它已修复。谢谢Md.Asaduzzaman。然后我将此添加为注释,并将其标记为正确答案。谢谢。