Several months ago we started to experience this error on all our SharePoint 2013/2016 farms.
Exception message: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromAssemblyCollection(IEnumerable`1 assemblies, Boolean buildingFromCache)
at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Note: This article is in draft yet and I’m still working on it.
Sometimes after moving SharePoint content (files, lists, sites, etc.) to a new place, you need to keep old links working. Sometimes you need to force users to use HTTPS instead of HTTP by redirecting them automatically. In these kinds of situation you can use the power of IIS URL Rewrite extension to achieve your goal.
If you have never worked with this extension, you can have a look at my post about it: Walkthrough: How to keep old SharePoint links working after a migration.
This post contains list of URL Rewrite rules which can be useful for SharePointers.
In this walkthrough I’ll show you a way how you can keep old links to SharePoint content working after a migration of a site or part of its content to a new place. This solution can help you in different scenarios when you change the content URL, but don’t want to ask your users to update their links.
In my case, I used this approach when I did a migration of inherited SharePoint 2010 to a new server. During the migration there was an upgrade to SharePoint 2013 and total revision and reorganization of the content structure. A lot of files were moved to new libraries and folders, some department sites were split up, while others were combined. The main challenge in this migration was the strong requirement that all the old links should keep working. The requirement was fulfilled and by now it has already been working in production for about a year without any issues.