views:

40

answers:

2

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?

+1  A: 

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://","");
}
Joel Etherton
+1  A: 

You're looking for the Uri class:

var uri = new Uri(someString, UriKind.Absolute);
var user = uri.UserInfo;
SLaks