How to mask tilde (~) character in C# MVC routing table?

Posted by AC on Stack Overflow See other posts from Stack Overflow or by AC
Published on 2010-06-04T23:19:33Z Indexed on 2010/06/07 7:32 UTC
Read the original article Hit count: 657

I'm moving my home-baked web site to MVC and got the trouble with url routing. The site already serves several links that contain tilde (~) character in the path; something like http://.../~files/... http://.../~ws/... and I want each of them are handled by separate controller, like filesController, wsController, so my route table looks like

routes.MapRoute( "files", "~files/{*prms}", new { controller = "files", action = "index", prms = "" } ); routes.MapRoute( "ws", "~ws/{*prms}", new { controller = "ws", action = "index", prms = "" } ); ...

but when I try to get the result I got the error saying "The route URL cannot start with a '/' or '~' character and it cannot contain a '?' character."

As I understand those characters have the special meaning in ASP.net but is it possible to mask them somehow, at least tilde? Should I parse and route requests like this myself? What the best practice to handle urls like this?

Thanks!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc