access to user.identity.name?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I've got a text-based .inc file that I'm using for my asp.net site's header.
I thought about a user control, but if possible, I'd like to avoid it for
simplicity's sake. In the main page, I do a response.writefile("header.inc")
for inserting the header. I have one render block:
<%= User.Identity.Name %>

Unfortunately, it seems that this is outputted as literal text to the
browser. I've tried a user control, but it doesn't seem to let me access this
property from the context of the user control. Is there any way to achieve
what I'm trying to do, ideally in the .inc, but via a user control would be
acceptable as well... ? Thanks for any help...

-Ben
 
Can you give more info on what your exact intended purpose is?

If you are trying to dump a string into the header of your page, how about a
label control. Then in code for page.load, set the text for the label

me.label1.text = user.identity.name
 
In a user control, use System.Web.httpContext.Current to access the
properties of the current HTTP request (Request,Response,Session etc...)
 
Thanks for the tip, Patrice. That's just what I was looking for. Out of
curiosity, why is it that I can't intrinsicly access the current httpcontext
from the user control, since the user control is placed on the main page? I
don't need to request the current httpcontext on the main page. Just
wondering. Thanks for the tip...

-Ben
 
You can also AFAIK. You have a Page property that allows to access to the
hosting page and in particular to the User property. Other information may
be reachable directly (such as Session).

I wanted to point on the original problme rahter to have to use include
files as a workaround...

Patrice
--
 
Back
Top