SPWeb.GetList() on an application page throws an exception ("Cannot Complete this Action") during postback. For some reason the first request to the application page seems to work.
on an application page I have the following code which works fine:
SPWeb contextWeb = SPContext.Current.Web;
SPList listByTitle = contextWeb.Lists["MyList"]; //works
SPList listByRelativeUrl = contextWeb.GetList("/sites/MySiteCollection/Lists/MyList"); //works
Then I call the exact same code from an event handler in the same application page
void Btn_Click(object sender, EventArgs e)
where
SPList listByTitle = contextWeb.Lists["MyList"]; //works
SPList listByRelativeUrl = contextWeb.GetList("/sites/MySiteCollection/Lists/MyList"); //throws
Background: I am creating lists via code during feature activation and would like to access them without displaynames / titles nor Guids after the deployment. Currently I use SPWeb.GetList() but I'd be interested in another approach as SPWeb.GetList() seems to perform rather poorly. Linq4SP is not an option due to the lack of support for anonymous users.