what's the difference...

G

Guest

hey all,

i was wondering what the difference is between obtaining a user name like

Request.ServerVariables("Auth_User").Split("\")(1))

and

User.Identity.Name

Is one newer than the other or something like that?

thanks,
ari
 
J

Juan T. Llibre

Request.ServerVariables("Auth_User").Split("\")(1))
uses a language feature to parse a server variable.

User.Identity.Name uses a native .Net property

Using a native .net class is usually more efficient
than using a Server Collection like ServerVariables.

When you load ServerVariables you load the whole collection.
That's quite a lot of data.
 
G

Guest

Thanks for the knowledge.

Juan T. Llibre said:
Request.ServerVariables("Auth_User").Split("\")(1))
uses a language feature to parse a server variable.

User.Identity.Name uses a native .Net property

Using a native .net class is usually more efficient
than using a Server Collection like ServerVariables.

When you load ServerVariables you load the whole collection.
That's quite a lot of data.
 
J

Juan T. Llibre

Hi, Clinton.

Some, although not all, of the Server Variables are collected
by System.Web.HttpRequest as individual properties.

See :
http://beta.asp.net/QUICKSTART/util...d50a3a&namespace=System.Web&class=HttpRequest

So, Request.ServerVariables("URL") is provided by System.Web.HttpRequest.Url
and Request.ServerVariables("APPLICATION_PHYSICAL_PATH") is
provided by Request.PhysicalApplicationPath.

Interestingly, the whole ServerVariables Collection is also provided
by System.Web.HttpRequest as a separate NameValueCollection,
so all the Request.ServerVariables are available, although at the
performance cost mentioned.

The HttpRequest class adds a few properties not found in Request.ServerVariables, too.
 

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
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top