我正在尝试在任何网站页面(仅包含HTML标记的简单网站页面)中获取有关登录用户的任何特定信息(ID,GUID ..)。 但我没有得到以下信息:
<%#
SPWeb theSite = SPControl.GetContextWeb(Context);
%>
我使用了以下代码剪切
<%#
SPWeb web = SPContext.Current.Web;
SPUser currentUser = web.CurrentUser;
%>
但是得到以下错误代码。
Compiler Error Message: CS1026: ) expected
Source Error:
Line 1343:
Line 1344: <%#
Line 1345: SPWeb web = SPContext.Current.Web;
Line 1346:SPUser currentUser = web.CurrentUser;
Line 1347:
答案 0 :(得分:0)
这将为您提供当前用户:
SPWeb web = SPContext.Current.Web;
SPUser currentUser = web.CurrentUser;
然后,您可以获得有关用户的所有信息,如姓名,电子邮件等:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser.aspx
在你的情况下试试这个:
<%= SPContext.Current.Web.CurrentUser.Email %>
我通常不使用内联代码,我不喜欢使用自定义控件来实现这类内容,因此不确定这是否有效。
答案 1 :(得分:0)
您还有此代码可以为您提供当前用户
this.Page.User.Identity.Name
跳这可以帮助!