Last active
June 22, 2016 15:16
-
-
Save duongphuhiep/13f104e4229bf7e1869921e034834ec6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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