原 URL:https://localhost/watch.aspx?id=123,加入 Routing 後變為 https://localhost/watch/123,導致頁面中引用的 JS、CSS、圖片等靜態資源全部 404,函數報「未定義」。
相對路徑(如 js/xxx.js、../js/xxx.js)在路由模式下會相對於虛擬目錄解析,而非網站根目錄。
/ 開頭。js/xxx.js → /js/xxx.js,$('#top').load('../head/head.html') → $('#top').load('/head/head.html')~ 符號標識應用程序根目錄。img.Src = "images/NEW.png" → img.Src = "~/images/NEW.png"此法不寫死域名/IP,適應部署環境變更。