【发布时间】:2017-12-09 11:39:42
【问题描述】:
我在开发中的一个项目时遇到了一个奇怪的问题。问题在于指向某个 URL“//localhost:62168/Images/Index”的链接。我有链接到该 URL 的按钮,但是当访问“//localhost:62168/Images/”时,它返回 HTTP 错误 403.14 - 禁止错误。见下图:
奇怪的是,当我准确输入 URL(“localhost:62168/Images/Index”)时,它会正确加载页面。见下图:
我在网上做了很多研究,我认为这可能是路由的问题,所以下面我添加了我的“RouteConfig.cs”文件的代码。不幸的是,我是 ASP.net 和 MVC 的新手,不了解正确的路由过程:
using System.Web.Mvc;
using System.Web.Routing;
namespace ReedHampton
{
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 = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
}
我还尝试了其他在线论坛中提供的多种其他“解决方案”,但均无济于事。其中包括:
- 在 web.config 中添加“directoryBrowse enabled="true"”
- 在命令提示符中运行“C:\windows\Microsoft.NET\Framework64\v4.0.30319> aspnet_regiis.exe -i”
- 通过 IIS Express 并注册 IIS Express 和 ASP.Net
如果有人能提供任何帮助,我将不胜感激!
【问题讨论】:
标签: asp.net asp.net-mvc iis routing http-error