我已经在ASP.NET应用程序中创建了路由规则,并且在IIS7上的开发机器上一切正常。当我将解决方案部署到也有IIS7的prod服务器时,在访问URL时出现错误404(找不到页面)。也许有人可以指出问题在哪里?路由HTTP错误404.0 0x80070002
实际的错误
HTTP错误404.0 - 未找到您正在寻找的 资源已经 删除,更名,或 暂时不可用。详细 错误InformationModule IIS Web核心 通知MapRequestHandler 处理程序StaticFile错误代码 0x80070002请求的URL http://xxx.xxx.xxx.xxx:80/pdf-button 物理路径 C:\ WWW \ pathtoproject \ PDF按钮登录 方法匿名登录用户匿名
我的实际代码
<add key="RoutePages" value="all,-forum/"/>
UrlRewrite.Init(ConfigurationManager.AppSettings["RoutePages"]);
public static class UrlRewrite
{
public static void Init(string routePages)
{
_routePages = routePages.ToLower().Split(new[] { ',' });
RegisterRoute(RouteTable.Routes);
}
static void RegisterRoute(RouteCollection routes)
{
routes.Ignore("{resource}.axd/{*pathInfo}");
routes.Ignore("favicon.ico");
foreach (string routePages in _routePages)
{
if (routePages == "all")
routes.MapPageRoute(routePages, "{filename}", "~/{filename}.aspx");
else
if (routePages.StartsWith("-"))
routes.Ignore(routePages.Replace("-", ""));
else
{
var routePagesNoExt = routePages.Replace(".aspx", "");
routes.MapPageRoute(routePagesNoExt, routePagesNoExt, string.Format("~/{0}.aspx", routePagesNoExt));
}
}
}
}
你使用什么类型的路由? MVC? – 2011-04-15 13:02:13
我用System.Web.Routing.RouteCollection类(.NET 4.0) – Tomas 2011-04-15 13:04:09
什么是你希望它被路由到 - PDF-button.aspx?正如我敢肯定你已经意识到0x80070002 = ERROR_FILE_NOT_FOUND – Rup 2011-04-15 13:39:04