0

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
  • From the current request or from a string? Commented Oct 31, 2010 at 16:20

2 Answers 2

3

You're looking for the Uri class:

var uri = new Uri(someString, UriKind.Absolute);
var user = uri.UserInfo;
Sign up to request clarification or add additional context in comments.

Comments

0

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://","");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.