Skip to content

Instantly share code, notes, and snippets.

@duongphuhiep
Last active June 22, 2016 15:16
Show Gist options
  • Save duongphuhiep/13f104e4229bf7e1869921e034834ec6 to your computer and use it in GitHub Desktop.
Save duongphuhiep/13f104e4229bf7e1869921e034834ec6 to your computer and use it in GitHub Desktop.
public static class UriExtensions
{
public static void GetUsernamePassword(this Uri uri, out string userName, out string password)
{
userName = string.Empty;
password = string.Empty;
if (uri == null || string.IsNullOrWhiteSpace(uri.UserInfo))
return;
var items = uri.UserInfo.Split(new[] { ':' });
if (items.Length > 0) userName = items[0];
if (items.Length > 1) password = items[1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment