我已經在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