KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to write a route with a nullable int in it. It should be possible to go to both /profile/ but also /profile/\d+ . routes.MapRoute("ProfileDetails", "profile/{userId}", new {controller = "Profile", action = "Details", userId = UrlParameter.Optional}, new {userId = @"\d+"}); As you can see, I say that userId is optional but also that it should match the regular expression \d+ . This does not work and I see why. But how would I construct a route that matches just /profile/ but also /profile/ followed by a number?
Tags (comma-separated)
Save Edits
Cancel