469,575 Members | 1,703 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

access to user.identity.name?

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
Jul 21 '05 #1
4 1588
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

"Ben R." wrote:
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

Jul 21 '05 #2
In a user control, use System.Web.httpContext.Current to access the
properties of the current HTTP request (Request,Response,Session etc...)

--

"Ben R." <Be**@discussions.microsoft.com> a écrit dans le message de
news:06**********************************@microsof t.com...
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

Jul 21 '05 #3
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

"Patrice" wrote:
In a user control, use System.Web.httpContext.Current to access the
properties of the current HTTP request (Request,Response,Session etc...)

--

"Ben R." <Be**@discussions.microsoft.com> a écrit dans le message de
news:06**********************************@microsof t.com...
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


Jul 21 '05 #4
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
--

"Ben R." <Be**@discussions.microsoft.com> a écrit dans le message de
news:3D**********************************@microsof t.com...
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

"Patrice" wrote:
In a user control, use System.Web.httpContext.Current to access the
properties of the current HTTP request (Request,Response,Session etc...)

--

"Ben R." <Be**@discussions.microsoft.com> a écrit dans le message de
news:06**********************************@microsof t.com...
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


Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

42 posts views Thread by lauren quantrell | last post: by
2 posts views Thread by Jesper Stocholm | last post: by
5 posts views Thread by Dave Kolb | last post: by
1 post views Thread by Jody Gelowitz | last post: by
11 posts views Thread by Eric | last post: by
1 post views Thread by cpajoe2001 | last post: by
2 posts views Thread by =?Utf-8?B?RWRkaWU=?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.