Reputation: 625
Is there any way to retrieve username from this
http://username@myapplication.com
type of address in ASP.NET MVC (optionally in ASP.NET) from current request?
Upvotes: 0
Views: 373
Reputation: 887777
You're looking for the Uri
class:
var uri = new Uri(someString, UriKind.Absolute);
var user = uri.UserInfo;
Upvotes: 3
Reputation: 37543
If that's the guaranteed string you might try something like:
string myString = "http://[email protected]";
if(myString.Contains("@"))
{
return myString.Split('@')[0].Replace("http://","");
}
Upvotes: 0