SharePoint has this funny mechanism ‘Alternate Access Maps’. Essentially, this means that the same content can be available via different web applications, which have different URLs.
But what do you do if you’ve an absolute URL to something in SharePoint, and you need it to be correct for the users’s current alternate access map zone?
Well, there is a function SPUtility.AlternateServerUrlFromHttpRequestUrl() – but I couldn’t see how to use it. Internally, it uses RebaseUriWithAlternateUri() – looks promising. And it works.
string url - "Absolute URL in the wrong zone";
SPUrlZone zone = SPContext.Current.Site.Zone;
Uri currentZoneUrl = SPFarm.Local.AlternateUrlCollections.RebaseUriWithAlternateUri(new Uri(url), zone);
I’m a bit suspicious of using the local SPFarm object, but that seems to work correctly. Others do seem to have done this:
I always find myself having to look this stuff up, and it’s nearly always for the same format of redirect, so here’s a reminder for myself. In SharePoint, you can redirect to a page in Layouts (in this case, the site settings page) with:
SPUtility.Redirect("settings.aspx", SPRedirectFlags.Static | SPRedirectFlags.RelativeToLayoutsPage|SPRedirectFlags.UseSource, HttpContext.Current);
This also will redirect to a
&source= get parameter if available. It also deals with the HIVE number (
/15/) in the URL automatically.
God, why is this so difficult? I needed to install the .NET framework 3.5 (for SQL Management Studio, dammit!) on my Windows 8.1 machine. You’re supposed to be able to do this from control panel (Programs and Feature > Turn on Windows Features > .Net 3.5). It didn’t work for me. Continue reading “Installing .NET Framework 3.5 on Windows 8.1″
Nearly all SharePoint farms I look at show the error:
Drives used for SQL databases are running out of free space
However, this seems to happen even on SharePoint farms where there is tonnes of space. It’s always puzzled me, and it results in many customers simply ignoring the warning, ‘cos they can’t figure out why they’re getting it, and having checked the drives they think they’re fine (and they probably are).
Well Zoltan Kovacs has a very good analysis. It’s well worth a read. Continue reading “Drives used for SQL databases are running out of free space”
I’ve been writing a client side object model script to set up some sites, including setting some the navigation settings on the site. Sadly, Microsoft have written SharePoint to involve at least 3 objects in the navigation settings for a site (PublishingWeb, WebNavigationSettings, and SPNavigation. At least. It’s totally effing bonkers.), and those objects don’t work in quite the same way for CSOM. For example, it’s not clear how to set a site to ‘show subsites’ in the global navigation. Continue reading “Set Global Nav in CSOM”
I was having a problem creating a new SPWebApplication through Central Admin in SharePoint. It would run for a fair while – longer than I’m used to as this machine seems quite slow – and then I’d be shown the IE ‘timeout’ page within the ‘Create Web App’ iframe. The Web App seemed to have created, including creation of the IIS app pool and site, but they never worked correctly – for example, on different attempts I couldn’t:
- See the web application’s settings in central admin
- Create a Site collection
- Login to a site collection that had created successfully, despite being site collection admin.
Fortunately, I’m not the first person to have seen this. Some folks suggest using PowerShell to provision the web application – which I’m guessing doesn’t suffer IIS timeouts – and others suggest increasing the time outs on the application pool itself. I set:
- Ping Maximum Response Time
- Shutdown Time Limit
- Startup Time Limit
… to 900 (instead of 90), I was able to create and successfully access my new site collection!
So setting up a new machine, I tried adding the Google search provider plugin for IE11; I wanted to add Google as my default provider rather than Bing. However, the Add-On kept failing to install:
The search provider could not be installed.
This might have happened because:
- A required file could not be downloaded
- The website is unavailable
- You are not connected to the internet
You might want to try again later.
Great. The problem was repeatable, and continued after reboot, and reset of IE’s settings. In desperation, I tried change the country that I was in (in the top right)…
I changed from United States to Turkey and back – and when I tried to add the extension, it installed without problem.
Hardly conclusive, but an interesting result nonetheless. Let me know if it works for anyone else!