0
我在MVC新的,定義爲我的路線遵循:MVC路由:生成多個過濾器參數之間的短跑在地址
routes.MapRoute(
name: "NewRoute",
url: "P/{colorname}-{id}/{statename}-{materialtype}-{HasPrice}",
defaults: new
{
controller = "Products",
action = "P",
id = UrlParameter.Optional,
statename = UrlParameter.Optional,
colorname = UrlParameter.Optional,
materialtype = UrlParameter.Optional,
HasPrice = UrlParameter.Optional
}
);
當用戶搜索在我的網站,我想表現出以下網址:
P /قیمت-نوعمواد-ناماستان/شماره-رنگ
,但得到404錯誤,並出示此URL:/ P/-/-
請幫我... 感謝s ...
感謝您的詳細解釋...但是當我使用這個ActionLink時,它會轉到myDefault路由...我的默認路由在NewRoute後定義..請幫助我... –
看起來您的話也可能有空格在他們之間,這是不允許的一個URL。請參閱[(請)停止在URL中使用不安全的字符](https://perishablepress.com/stop-using-unsafe-characters-in-urls/)以查看URL中允許和不允許使用哪些字符的細目。我建議你使用佔位符字符或標記作爲空間,讓你的應用程序在令牌到達你的控制器之前做一個替換,例如在值提供程序或過濾器中。 – NightOwl888