1
我有一個webforms-project,我使用System.Web.Routing.RouteCollection.MapPageRoute來重寫URL,但我有一些動態URL的問題。我的網址可能是這樣的;MapPageRoute中的通配符
/folder/city-1-2-something.aspx
和的MapPageRoute這個看起來像這樣
routeCollection.MapPageRoute("CompanyCity", "folder/city-{id}-{pid}-{title}.aspx", "~/mypage.aspx");
但我已經意識到,某些URL可能看起來像這樣
/folder/city-2-2-something-something.aspx
/folder/city-2-2-something-something-something.aspx
/folder/city-2-2-something-something-something-something.aspx
和這些都不是我的路由正確毫無遺漏 - 第一個示例將以結果id = 2-2和pid =結束,而不是id = 2和pid = 2結束。
{title}並不重要 - 只使用{id}和{pid}。我有幾個類似的路線到特定的文件夾,所以據我可以我不能使用一個捕獲所有。但我該如何解決這個問題?