Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. public static class UriExtensions
  2. {
  3. public static void GetUsernamePassword(this Uri uri, out string userName, out string password)
  4. {
  5. userName = string.Empty;
  6. password = string.Empty;
  7. if (uri == null || string.IsNullOrWhiteSpace(uri.UserInfo))
  8. return;
  9.  
  10. var items = uri.UserInfo.Split(new[] { ':' });
  11. if (items.Length > 0) userName = items[0];
  12. if (items.Length > 1) password = items[1];
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement