开发者

ASP.NET (MVC) Get username from URL http://username@myapplication.com

Is ther开发者_运维技巧e 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?


You're looking for the Uri class:

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


If that's the guaranteed string you might try something like:

string myString = "http://username@myapplication.com";

if(myString.Contains("@"))
{
    return myString.Split('@')[0].Replace("http://","");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜