username!

R

rcoco

Hi all,
I'm working with website and I'm using Authentication. This code makes
it work:
Page.User.Identity.Name; But my problem is that it comes in this
format: Domain/Loginname, yet I only wanted Loginname. What should I
do?
Thanks.
 
G

Guest

Hi all,
I'm working with website and I'm using Authentication. This code makes
it work:
Page.User.Identity.Name; But my problem is that it comes in this
format: Domain/Loginname, yet I only wanted Loginname. What should I
do?
Thanks.

Look for a slash and take the rest of the string.
 
M

Mark Rae

I'm working with website and I'm using Authentication. This code makes
it work:
Page.User.Identity.Name; But my problem is that it comes in this
format: Domain/Loginname, yet I only wanted Loginname.
What should I do?

A tiny bit of programming...

string strLoginName = Page.User.Identity.Name.Split('/')[1];
 
R

rcoco

Thanks,
I get this error: Index was outside the bounds of the array. Why is it
so?
Thanks
 
R

rcoco

Thanks,
I it has this slash : \ but when I try this :
string strLoginName = Page.User.Identity.Name.Split('\')[1]; I get the
following errors:
) expected,
; expected,
Newline in constant,
Too many characters in character literal.
What could i do?
 
M

Mark Rae

Thanks,
I it has this slash : \ but when I try this :
string strLoginName = Page.User.Identity.Name.Split('\')[1]; I get the
following errors:
) expected,
; expected,
Newline in constant,
Too many characters in character literal.
What could i do?

Well, if you have a quick look at your original post, you'll see that you
told the group that the name was contained a forward slash, not a
backslash...

That's why I advised you to use:
string strLoginName = Page.User.Identity.Name.Split('/')[1];

Now you say that the name contains a backslash, not a forward slash....

The backslash character in C# strings is treated as the escape character -
therefore, you need to use this:
string strLoginName = Page.User.Identity.Name.Split('\\')[1];
 
G

Guest

Thanks,
I it has this slash : \ but when I try this :
string strLoginName = Page.User.Identity.Name.Split('\')[1]; I get the
following errors:
) expected,
; expected,
Newline in constant,
Too many characters in character literal.
What could i do?

string strLoginName = Page.User.Identity.Name.Split('\\')[1];
 
R

rcoco

Thanks,
Method 'string.Split(params char[])' referenced without parentheses
Why this?
Thanks
 
R

rcoco

Hey Thanks to both
I got it it's working properly. Thankyou very much for the help.
Thanks again
 
R

rcoco

Oh! here comes Another problem I'm Not supposed to use Loginname
anymore I'm supposed to use username is there anyway I can Do it?
Thanks
 
G

Guest

Heh. I found a $100 bill, but it's stuck to a piece of bubble gum. What
should I do?
:)
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Mark Rae said:
I'm working with website and I'm using Authentication. This code makes
it work:
Page.User.Identity.Name; But my problem is that it comes in this
format: Domain/Loginname, yet I only wanted Loginname.
What should I do?

A tiny bit of programming...

string strLoginName = Page.User.Identity.Name.Split('/')[1];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top