So, I've got a sharepoint app... which is provider hosted (website in Azure).
The app works great... except for the very first click opening the app.
My pages all have the following in their Page_PreInit... when I open the app from SP (vs just copying/pasting the URL). oftentimes (not 100% of the time, but often times), I get the Response.Write("An error occurred while processing
your request.");
When I get the error, I can LITERALLY select the URL in the address bar, and click enter - refresh the page - and it works perfect.
Does anyone have ANY idea on why the 'initial' application request would fail, but then upon clicking the page and clicking enter, and/or copying the URL and entering it works just fine?
protected void Page_PreInit(object sender, EventArgs e)
{
Uri redirectUrl;
switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
{
case RedirectionStatus.Ok:
return;
case RedirectionStatus.ShouldRedirect:
Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
break;
case RedirectionStatus.CanNotRedirect:
Response.Write("An error occurred while processing your request.");
Response.End();
break;
}
}