SharePoint 2010 Custom Action Error on Call to ASPX Application Page – Potential IE8 Problem !!!

I had an unusual error with a slight twist – I had developed a Custom Action, based on right-click of the ECB menu for an item.  Selecting this option would call an ASPX application page.  The way I had designed this overall Custom Action was as follows:-

1) Sandboxed solution for the custom action, which calls an ASPX application page.   This is because I did not want the custom action to be farm level as the right-click action only applies to a specific list within a site collection.

2) A farm level solution to deploy the application page – the application page actually implements functionality to put some of the item level information passed through the query string that calls the page, into a single database table, where the connection string is stored within a SharePoint 2010 Secure Store area.  I made sure that all users within the domain could access the required connection string from the secure store.

The overall functionality worked fine, but kept failing on the users machine.  The error was a straight and simple SharePoint 2010 error with some correlation id, which after looking into showed a Null Reference error.  The initial assumption I made was that the code for the page was never getting executed on the users machine, and therefore it had to be a security error.  After further investigation I had discovered that I could not get the page to execute it’s code even when signing on as myself on the users machine.  The difference between the users machine and my machine was that I was accessing the page successfully from the custom action, through using IE9 , the user on the other-hand was using IE8.  Therefore the issue with the Null reference was most likely code.  The specific code that was failing turned out to be the following:-

if (!Page.IsPostBack){

  string prevPage = = Page.Request.UrlReferrer.ToString();


It turns out that IE8, does not pass the calling URL to the application page when someone tries to access the page by a right-click on the ECB Menu, therefore the Request.UrlReferrer  was returning a NULL value, which was causing the page to crash out.  So just like Microsoft Dynamics CRM, it is important to understand and remember that browsers can exhibit different behaviours for different applications.

Getting back to my problem – I really needed to get the value of the URL to the calling page, as I wanted to execute the code in the application page and return the user back to the original page showing the list items.  The answer in the end is to construct a string with the following variables that should be available to you:-

string prevPage = Web.Url + “/Lists/{your list name with space characters replaced with %20}/AllItems.aspx”

the final solution resolved the problem, and so the ECB menu option works in both IE8, and IE9.  Please note I did not have time to find the reason why the URL was not passed in IE8, other than the fact that it has something to do with security.  Hope this helps someone out there.


Leave a Reply