c# - 使用 ASP.NET MVC 和 IIS 10 浏览网站时出现错误 404
问题描述
我目前正在使用 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
编辑:上一个操作不应该返回视图,我尝试了另一个应该返回视图的操作,但仍然是 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 }
);
}
}
解决方案
更新:我试图访问http://localhost:80/Monitoring/ViewHistory
但控制器位于C:\ProjectsTfs\idkids\Sprint-16\IdKids.Batchs\LifeTest\Monitoring\ViewHistory
. 当尝试访问http://localhost:80/lifetest/Monitoring/ViewHistory
(使用适当的参数)时,一切正常。
推荐阅读
- javascript - 为什么函数一结束我的数组就变得未定义?
- html - 流动和固定的网页
- mongodb - 在猫鼬中查找和更新子元素?
- arm - 如何在 stm32f429zi 中使用循环模式?
- c - c中队列的数组实现
- python - 为什么'不在'返回 True 与包含其内部列表中的引用值的二维列表
- at-command - SIM800L:AT+CIICR 总是进入 PDP DEACT 状态
- java - PriorityQueue (Java) 的字符串排序问题
- kubernetes - 如何暂停然后恢复谷歌云中的 Kubernetes 服务?
- python - Python中的颜色,标签