How to parse and rebuild a URL in ASP.Net?

I am developing a C # / ASP.Net application, and I am trying to find a way to break down a URL into its component parts, then replace or remove these parts and create a new URL.

For example, if I have the following URL:

I would like to split the url into:

  • Protocol (http, https, ftp, etc.)
  • Domain (www.site.com)
  • Page (page.aspx)
  • URL parameters (parm1 = value1, parm2 = value2)

Once the URL is split, I would like to manipulate each of the parts, for example:

  • add or remove options
  • change parameter value
  • change the page from page.aspx to page2.aspx

Then, as soon as I am done, create a new URL ready for use with the above changes.

MSDN .Net, . ?

Cheers,

+3
2

UriBuilder .

/ , :

UriBuilder, Uri, Uri, ToString(), URL- .

+4

UriBuilder (. driis).

Query:

NameValueCollection q=HttpUtility.ParseQueryString(uri.Query);

HttpValueCollection (), , q.ToString(), , URL-.

,

NameValueCollection q=HttpUtility.ParseQueryString("");

.

0

Source: https://habr.com/ru/post/1765850/


All Articles