我目前正在使用ASP.NET MVC创建一个网站。我在页面中有多个链接,但是它们都不起作用,它们都返回404错误。问题在于该页面确实存在,并且控制器中的动作也存在。这是错误页面上给出的详细错误信息:
Detailed Error Information:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002
Requested URL: http://localhost:80/Monitoring/CheckStatusTaskenvironnementId=1&serviceId=4&taskId=2
Physical Path: C:\ProjectsTfs\idkids\Sprint16\IdKids.Batchs\LifeTest\Monitoring\CheckStatusTask
Logon Method: Anonymous
Logon User: Anonymous
编辑 :上一个操作不应该返回View,我尝试了另一个应返回View的操作,但仍然出现404错误。详细的错误信息如下:
Detailed Error Information:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002
Requested URL: http://localhost:80/Monitoring/ViewHistory?environnementId=1&serviceId=1&taskId=1
Physical Path: C:\ProjectsTfs\idkids\Sprint-16\IdKids.Batchs\LifeTest\Monitoring\ViewHistory
Logon Method: Anonymous
Logon User: Anonymous
如建议的那样,以下是在控制器中处理此操作的代码:
public ActionResult ViewHistory(int environnementId, int serviceId, int taskId)
{
var model = _batchLogBusiness.GetTaskLog(environnementId,serviceId, taskId, false);
return View(model);
}
这是RouteConfig
类:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Monitoring", action = "Index", id = UrlParameter.Optional }
);
}
}
答案 0 :(得分:0)
更新 :我试图访问http://localhost:80/Monitoring/ViewHistory
,但控制器位于C:\ProjectsTfs\idkids\Sprint-16\IdKids.Batchs\LifeTest\Monitoring\ViewHistory
下。尝试使用适当的参数访问http://localhost:80/lifetest/Monitoring/ViewHistory
时,一切正常。