我在内部使用SharePoint 2019进行自定义操作时遇到问题。自定义操作在SharePoint菜单栏的菜单项中添加一个链接。这是一个mysite集合。
SharePoint 2013(有效): https://ibb.co/PxM0wzP
在SharePoint 2019中没有链接(已部署网站集功能),请参见此处: https://ibb.co/bRtkQXw
疯狂的事情是在 Person.aspx上不可见。在default.aspx上添加了: https://ibb.co/XW2qh4h
在旧版本的SharePoint 2013上运行良好。我不知道为什么不将它添加到person.aspx
以下是自定义操作类的代码:
public class EditProfileCustomLink : SPSecurityTrimmedControl
{
protected MenuItemTemplate menuItem;
protected override void CreateChildControls()
{
base.CreateChildControls();
SPUser currentuser = SPContext.Current.Web.CurrentUser;
SPWebApplication webApplication = SPContext.Current.Site.WebApplication;
if (currentuser != null && webApplication != null && webApplication.UserSettingsProvider != null )
{
try
{
// Get the assigned settings provide
SPUserSettingsProvider usp = webApplication.UserSettingsProvider;
// Get the source url
string sourceUrl = SPContext.Current.Site.MakeFullUrl(HttpContext.Current.Request.RawUrl.ToString());
sourceUrl = SPHttpUtility.HtmlEncode(DeltaPage.RemoveDeltaQueryParameters(sourceUrl));
string editProfileUrls = string.Format("~site/_layouts/15/EditProfile.aspx?UserSettingsProvider={0}&ReturnUrl={1}",
Uri.EscapeDataString(usp.ProviderIdentifier.ToString()),
sourceUrl);
// Initialize the menu item
this.menuItem = new MenuItemTemplate();
this.menuItem.Title = SPUtility.GetLocalizedString("$Resources:EditProfile", Constants.ResourceFile, (uint)CultureInfo.CurrentUICulture.LCID);
this.menuItem.Text = SPUtility.GetLocalizedString("$Resources:EditProfile", Constants.ResourceFile, (uint)CultureInfo.CurrentUICulture.LCID);
this.menuItem.Description = SPUtility.GetLocalizedString("$Resources:EditProfile", Constants.ResourceFile, (uint)CultureInfo.CurrentUICulture.LCID);
this.menuItem.Sequence = 1040;
this.menuItem.Visible = true;
this.menuItem.ClientOnClickNavigateUrl = editProfileUrls;
// Add custom menu item
this.Controls.Add(menuItem);
}
catch (Exception ex)
{
Logger.Instance.LogError(LogCategory.Web, String.Format("Error while creating edit profile link '{0}'", ex));
}
}
}
}
elements.xml:
<CustomAction
Id="29F3F98A-5338-41A3-BFAD-ECEED235873D"
GroupId="PersonalActions"
Location="Microsoft.SharePoint.StandardMenu"
ControlAssembly="$SharePoint.Project.AssemblyFullName$"
ControlClass="Brose.ProfileDisplay.Source.EditProfileCustomLink">
</CustomAction>