I have four zones(Default, Intranet, Internet and Extranet) configured for my web application. Each zone is having different URL. I am developing a web part which needs to display the links to the News Archieve and my aim is to display the Latest News. What would be the best to get the relative URL of the news item and to avoid the broken link in the webparts for each zone? I am using the following code which is blindly getting the Site URL(which is my default Zone URL).
NewsHelper helper = new NewsHelper();
List<LatestNewsItem> newsList = new List<LatestNewsItem>();
using (SPSite site = new SPSite(SiteUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList(ListName);
if (list != null)
newsList = helper.GetLatestNews(list);
}
}