简体   繁体   English

MVC 路由问题?

[英]Issue with MVC Routing?

I have an issue in Routing in MFA where link like我在 MFA 中的路由中有一个问题,链接如下

  • Project_Name\\Controller\\Index is working, whereas Project_Name\\Controller\\Index正在工作,而
  • Project_Name\\Controller\\ is not working Project_Name\\Controller\\不工作

This is happening for only some controllers after being deployed in a server.在服务器中部署后,仅某些控制器会发生这种情况。

I am getting the following error:我收到以下错误:

403 - Forbidden: Access is denied.You do not have permission to view this directory or page using the credentials that you supplied. 403 - 禁止:访问被拒绝。您无权使用您提供的凭据查看此目录或页面。

Is there any further configuration values that needs to be considered?是否还有其他需要考虑的配置值?

In RouteConfig we define the route path like this在 RouteConfig 我们像这样定义路由路径

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

So the controller you are using may have Index action method and the URL works.因此,您使用的控制器可能具有 Index 操作方法并且 URL 有效。 But if your controller does not contain Index method or it is having parameters then it will not work.但是如果你的控制器不包含 Index 方法或者它有参数,那么它就不会工作。

This is a possible solution that you might create an action method named Index in all those controllers.这是一个可能的解决方案,您可以在所有这些控制器中创建一个名为 Index 的操作方法。 for more, you need to share some more details.如需更多信息,您需要分享更多细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM