I have a url along the lines of this:
example.com/profile/publicview?profileKey=5
and I want to shorten it to this with routing
example.com/profile/5
How do I do this?
This is my attempt:
routes.MapRoute(
"Profile", "Profile/{profileKey}",
new { controller = "Profile", action = "PublicView", profileKey ="" }
);
But his produces this error:
The parameters dictionary contains a null entry for parameter 'profileKey' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult PublicView(Int32)' in 'Website.Controllers.ProfileController
Action method
public ActionResult PublicView(int profileKey)
{
//stuff
}