<%=HttpContext.Current.User.Identity.Name %>
現在のユーザー名を表示します HttpContext.Current.User
はIPrincipalオブジェクトを取得します。ここで
はタイトルだけでユーザー名を表示するマスターページです:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
<link href="../../Content/Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
<h1 id="maintitle">
<%=HttpContext.Current.User.Identity.Name %>
</h1>
</div>
</div>
<div id="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</div>
</body>
</html>
は、このアドオンは受け入れ答えと比べない何と思いますか? – beresfordt
'Page.User'は' HttpContext.Current.User'よりも何らかの形で見えます。彼らは同じことをするので、ちょうど味の問題。 –
私はあなたが何を言っているのか理解できていません –