Wednesday, September 15, 2010

SharePoint and reverse proxy

Yesterday I had to deploy a new SharePoint Solution to one of our customers. We had tested the Solution on our local machines and on the staging server. Everything was fine. After we installed the solution on their integration and quality server we realized that some WebParts threw an exception:

"System.ArgumentException: Value does not fall within the expected range.     at Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder)     at Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32& plItemId, Int32& plType, Object& pvarFileOrFolder)     at Microsoft.SharePoint.SPWeb.GetMetadataForUrl(String relUrl, Int32 mondoProcHint, Guid& listId, Int32& itemId, Int32& typeOfObject, Object& fileOrFolder)     at Microsoft.SharePoint.SPWeb            fce4297d-3e08-415c-81f5-09bb40ea0820"

The only difference betweeen our enviroment and theirs was a reverse proxy. After some logging I found out that the method "HttpContext.Current.Request.Url.Scheme" returns "http://domain/list" and the webapplication runs on "https://domain". The returned url is used to access a list by SPWeb.GetList(), which returns null. The reverse proxy is situated in front of the web application and changes the connection to https. But the httpcontext within the application returns http.

Learning was that you should build up your staging environment the same way your customer does.

No comments: