what's the difference...

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.




Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
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.




Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 
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.



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
 

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

Back
Top