在代码中读取当前站点/网站集术语库存储页面URL [英] Read current site/site collection term store navigation page URL in the code
问题描述
在Share Point 2013网站(内部开发环境)上,在主页中我们有一个Web部件,我们在哪里显示术语(从术语库导航中读取)。我们通过对术语商店导航页面URL和所需用户名和密码进行硬编码来访问该术语商店导航页面。
但是当我们部署WSP时其他服务器它不会工作。那么有没有办法阅读当前的网站/网站集术语商店导航页面URL?而不是硬编码用户名和密码,我们如何使用提升的权限运行?
我尝试过:
试图在代码中读取术语商店导航页面URL,但不能正常工作。
On a Share Point 2013 site (on premise Dev Environment), in the home page we have a web part, Where we are displaying the terms (reading from Term store navigation). We are doing this by hard coding the term store navigation page URL and Required user name and password to access that term store navigation page.
But when we deploy the WSP in other servers it’s not going to work. So is there any way to read current site/site collection term store navigation page URL? And instead of hard coding the User name and password, how can we run with elevated privileges?
What I have tried:
tried to read term store navigation page URL in the code, but not working.
推荐答案
您必须从自定义代码中的配置文件/列表中动态读取导航页面URL,或使用以下代码动态读取术语库URL。
SPSecurity.RunWithElevatedPrivileges(代表
{
SPWeb web = SPContext .Current.Web;
string siteurl = SPContext.Current.Site.Url;
TaxonomySession session = new TaxonomySession(SPContext.Current。网站);
TaxonomyNavigationContext tnx = TaxonomyNavigationContext.Current;
}
Hi,
you have to read the navigate page url dynamically from the configuration file /list in custom code or use the below code to read term store url dynamically.
SPSecurity.RunWithElevatedPrivileges(delegate
{
SPWeb web = SPContext.Current.Web;
string siteurl = SPContext.Current.Site.Url;
TaxonomySession session = new TaxonomySession(SPContext.Current.Site);
TaxonomyNavigationContext tnx = TaxonomyNavigationContext.Current;
}
这篇关于在代码中读取当前站点/网站集术语库存储页面URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!