mvc 標準的寫法 通常是(http://localhost:8149/home/index) 路由配置如下:
有時候需求 如 http://localhost:8149/home/index 改為http://localhost:8149/index.html 讓其看起來更加像乙個靜態**
//配置首頁 偽靜態 路由然而routes.maproute("pc_index", "index.html", new );
解決方式一(不建議)修改 web.config 檔案
這種方式強烈不建議:1、這些問題的形式是使所有註冊的http模組在每個請求上執行,而不僅僅是託管請求(例如.html)。 這意味著模組將永遠執行.jpg .gif .css .aspx等2、浪費資源
3、並具有可能導致錯誤的全域性效應
更好的解決方案(方式二)
更好的解決方案(方式三)
MVC 偽靜態路由
定義url html.actionlink html get page new 這url是呼叫本控制器下面的的get page方法,傳參id 定義路由 routes.maproute name urlhtml url html 註冊路由 routeconfig.registerroutes rout...
mvc 路由偽靜態實現
很多 都採用偽靜態,例如以html shtml等結尾的url,mvc的路由可以輕鬆實現。mvc的路由原理是從上往下匹配的,所以只需要在後面新增自己配置的路由即可 public static void registerroutes routecollection routes axd routes.m...
mvc 路由偽靜態實現
很多 都採用偽靜態,例如以html shtml等結尾的url,mvc的路由可以輕鬆實現。mvc的路由原理是從上往下匹配的,所以只需要在後面新增自己配置的路由即可 public static void registerroutes routecollection routes axd routes.m...