[Sharepoint] – DataContext with custom URL
Jan 27
.NET, Sharepoint datacontext, sharepoint, spmetal No Comments
Hello,
One of these days I had to do some bugfixing on a Sharepoint project which used the Microsoft.SharePoint.Linq.DataContext class.
While trying to access a SPList belonging to Site Collection another Site Collection I always add an “Invalid Url Exception” right from the contructor, and other times I had exceptions when accessing the objects.
var context = new DataContext(otherSiteColUrl);
The problem is that inside, the constructor, the URL is only taken into account if we have no HttpContext. If we do have one, the context URL (which means, the current site url) the custom url passed on the constructor is ignored.
More

