Search code examples
c#asp.netasp.net-mvcasp.net-routing

Users enter Forward Slash "/" in asp.net MVC 3 url


Using .Net 4, isn't it possible to include forward slash in route parameters or one should force the user to use hyphen - instead

Example: mysite.com/user/{id}/{year} maps to mysite.com/user/01/2012

where {id} = {user/01} and {year} = 2012 in the example above

if this is the last route parameter it would be easier as pointed in the answers below. but it is not

I have read these, same questions as mine

but I didn't really get what I want. I could use this solutions if I want to generate the URL.

But what happens if the use type the url in the browser?

Or one should avoid that and force the user to use other formats like replacing "/" with "-"? as: mysite.com/user/usr-01/2012


Solution

  • Loosely interpreted: Can a route-parameter include a forward-slash ?

    Answer: No. Just avoid that.