hildk
hildk

Reputation: 159

Passing a username into a url

I'm trying to set my user variable in my link equal to the current user's username.

Here is what I have:

<li><a runat="server" href="~/Profiles?user=<%: Context.User.Identity.GetUserName() %>">Profile</a></li>

The url that I end up getting is this:

/Profiles?user=<%:%20Context.User.Identity.GetUserName()%20%>

How do I amend my code to properly place the username in the url?

I'm using the webforms template and identity 2.0

Upvotes: 2

Views: 1050

Answers (1)

Rahul
Rahul

Reputation: 77896

You can get the HREF attribute set at runtime though like

Design:

<li><a id="A1" runat="server">Profile</a></li>

In Code:

this.A1.HRef = "~/Profiles?user=" + Context.User.Identity.Name;

Upvotes: 1

Related Questions