开发者

Using an actual tilde in a URL Route

I need to set up routing in global.asax so that anybody going to a certain page with an actual tilde in the URL (due to a bug a tilde ended up in a shared link) is redirected to the proper place using routing. How can I set up a route for a URL with an ACTUAL tilde ("~") in it, e.g. 开发者_Python百科www.example.com/~/something/somethingelse to go to the same place as www.example.com/something/somethingelse - it never seems to work!


In addition to Gerrie Schenck:

You should NEVER ever use unsafe characters in URL's. It's bad practice and you can not be sure that all browsers will recognize this character.

Webdevelopment is about creating websites/webapplications that will function under all browsers(theoretically ofcourse, practically it resolves to a limited few that are used the most based on the goal it serves: p )

The encoding should work, if not, it proves Gerrie and my point as why you should not use unsafe characters.

List of unsafe characters and which encoding could be used: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm


You could try escaping the tilde, but I doubt this will work since it's an unsafe character, meaning it should never be used in an URL.

For example:

www.example.com/%7E/something/somethingelse

%7E is the escape code for a tilde.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜