单击图像时如何解决此错误 [英] How Can I Solve This Error When I Click On Image

查看:68
本文介绍了单击图像时如何解决此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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: /Home/Index.aspx

推荐答案

在MVC中你不需要指定。 aspx或cshtml扩展

简单地如下所示

In MVC you no need to specify the .aspx or cshtml extension
Simply put like below
/Home/Index



希望这有帮助


Hope this helps


你的网址应该有意义



your URL should be meaningful

/ControllerName/ActionName

/Home/Index



主页 - > ControllerName

索引 - >该控制器中的ActionName


Home -> ControllerName
Index -> ActionName with in that Controller


您应该了解MVC中的路由。这是一个简单的问题。

因为你正在使用MVC,所以它处理内部的控制器和动作。

这是发送请求的时候,mvc路由器默认需要一个控制器和一个带参数的动作如果有的话。

您可以在App_Start-> Routeconfig.cs中查看上述声明

You should understand the routing in MVC. This is a simple issue.
Since you are using MVC, this deals with controller and Actions inside.
That is when the request is send, mvc router by default expects a controller and an action with parameters if any.
You can check the above statement inside the App_Start->Routeconfig.cs
public static void RegisterRoutes(RouteCollection routes)
       {
           routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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





这是路线的样子。因此,当您键入Index.aspx / Index.cshtml(如果是Razor)时,它将抛出404未找到错误,因为在Home控制器中没有这样的Action存在Index.aspx名称。

我希望这清除您的查询。

谢谢。



This is how the route looks. So when you type Index.aspx/Index.cshtml(if Razor), then it will throw 404 not found error as no such Action exists inside Home controller with Index.aspx name.
I hope this clears your query.
thanks.


这篇关于单击图像时如何解决此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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