Ashwin
Ashwin

Reputation: 441

Invalid URL as a Valid URL in C#

how can i add the invalid url (but its valid as it is internal URL) as a valid URL, i am getting an error when i am passing it to System.Uri();

Here is my Uri Code

new System.Uri("mailto:DFO%20ABNS%20Techn/DD-DWA/IND@ADW-NGP", true)

Upvotes: 0

Views: 394

Answers (1)

tolanj
tolanj

Reputation: 3724

According to this http://www.ietf.org/rfc/rfc6068.txt / should be %-encoded in mailto 'address-part'. .Net will happily take:

new System.Uri("mailto:DFOTechn/DD-DWA/IND@ADW-NGP");

But it is all considered as part of the host.

encoding the '/' characters gives:

new System.Uri("mailto:DFO%20ABNS%20Techn%2FDD-DWA%2FIND@ADW-NGP")

Which .Net correctly parses with ADW-NGP as the host.

Upvotes: 2

Related Questions