我有以下網址如何從asp.net MVC4中的動態url獲取參數?
http://localhost/user/MyUserName
如何獲得 「MyUserName輸入」 從該網址是什麼?所以我可以在服務器端使用它來檢索我想要呈現給客戶端的信息?
在Django中,很簡單地將其歸檔。但是,我如何在ASP.net MVC4中做到這一點?
編輯
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
MyUserName輸入總是最後「參數」 ? –
@Exsaliver沒有那是url的動態部分。它可以是任何東西。但我想要這個參數,所以我可以從數據庫中獲取用戶數據。 – starcorn