C# 如何将用户名从子布局传递到Sitecore中的当前布局?

C# 如何将用户名从子布局传递到Sitecore中的当前布局?,c#,asp.net,.net,visual-studio,sitecore,C#,Asp.net,.net,Visual Studio,Sitecore,在我的Sitecore解决方案中,我希望在布局上显示登录用户的用户名。用户名已在子布局中确定。您可以使用 System.Web.HttpContext.Current.User or Sitecore.Context.User.Name 在您的布局aspx页面中 如果这对你不管用,你可以考虑。在eventArgs中,您将传递在子布局中确定的当前用户的名称。基本上,您可以将Sitecore的事件池功能用于API调用,例如 //in the sublayout Sitecore.Events.E

在我的Sitecore解决方案中,我希望在布局上显示登录用户的用户名。用户名已在子布局中确定。

您可以使用

System.Web.HttpContext.Current.User 
or
Sitecore.Context.User.Name
在您的布局aspx页面中

如果这对你不管用,你可以考虑。在eventArgs中,您将传递在子布局中确定的当前用户的名称。基本上,您可以将Sitecore的事件池功能用于API调用,例如

//in the sublayout
Sitecore.Events.Event.RaiseEvent("eventName", someObject);

//in the Layout
Sitecore.Events.Event.Subscribe("eventName", eventHandlerRef);//where eventHandlerRef is a method with the parameters (object, EventArgs)
Sitecore.Events.Event.Unsubscribe("eventName", eventHandlerRef);