私はこれに沿ったURLを持っています:
example.com/profile/publicview?profileKey=5
ルーティングでこれに短縮したい
example.com/profile/5
どうすればよいですか?
これは私の試みです:
routes.MapRoute(
"Profile", "Profile/{profileKey}",
new { controller = "Profile", action = "PublicView", profileKey ="" }
);
しかし、彼はこのエラーを生成します:
パラメータディクショナリには、'Website.Controllers.ProfileController'のメソッド'System.Web.Mvc.ActionResult PublicView(Int32)'のnull許容型ではないタイプ'System.Int32'のパラメータ'profileKey'のnullエントリが含まれています
アクションメソッド
public ActionResult PublicView(int profileKey)
{
//stuff
}