2
我在我的ASP.NET應用程序中使用路由。ASP.NET路由。默認頁面
我想要做什麼,如果用戶輸入一些錯誤的URL,他應該被重定向到pagenotfound.aspx
例子:
http://mysite/product/ //<- OK. Goes to all products
http://mysite/product/ipad //<- OK. Goes to ipad product
http://mysite/somerandomstuff/ //<- NOT OK!! This one should go to pagenotfound.aspx Now I`m getting error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The resource cannot be found.
我的代碼是:
//works ok
routes.MapPageRoute(
"products-all",
"product",
"~/products.aspx");
//works ok
routes.MapPageRoute(
"products-category",
"product/{category}",
"~/product.aspx");
//does not work!!!
routes.MapPageRoute(
"pagenotfound",
"", // <-- what should be here????
"~/pagenotfound.aspx");
謝謝你
也許這可能是一些幫助http://stackoverflow.com/a/14586192/1236044 – jbl 2013-04-26 08:49:25