开发者

Include url inside url

I want t开发者_StackOverflow社区o use the following format of my url:

http://localhost/{url}/{options}/{hash}

But since the url will be very strange with a url inside a url, how would I encode that?

I was thinking of encoding it in hex, since url encoding in .net gave me some strange result that didn't work inside a url. But I don't really know what would be the best way here.

I want to keep the structure of the url, not including any querystring.


You can use System.Web.HttpUtility.UrlEncode method to encode parts of the url (even another url).

If it's a part of the path and not the query string, UrlPathEncode should do the job.


If you don't want the querystring part, then why do you want to encode the url part?

The following url is completely valid:

http://localhost/www.stackoverflow.com/1234/abc

As stated in this RFC, characters, "-" and "." are allowed in a URI.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜