Web サイトのユーザーが独自のバニティ URL を指定して変更できるようにしようとしています。
選択した URL をデータベースに保存し、それを呼び出してユーザーに再ルーティングします。
今のところこれは私が持っているものですが、ここからどこへ行くべきか本当にわかりません.
routes.MapRoute(
"User", // Route name
"User/Profile/{id}", // URL with parameters
new { controller = "User", action = "Profile", id = UrlParameter.Optional }, // Parameter defaults
new string[] { typeof(MvcApplication).Namespace + ".Controllers" }
);
バニティ URL を取得して PersonID に再ルーティングする方法はありますか?
また、ActionResult を操作して文字列 Vanity Url または int PersonID を処理しようとしましたが、正しい方向に進んでいないように見えたので、routes.Maproute に戻りました。
編集:
ユーザーが入力できるようにしたい
http://localhost:60619/User/Profile/Vanity
入ったときと同じ場所にたどり着きます
http://localhost:60619/User/Profile/224 Assuming the PersonID is 224
アクション結果:
public ActionResult Profile(int ID)
{
ppUser viewerChoice = DB.ppUser_GetUserByPersonID(ID);
return View(ID);
}