I have a situation where it is possible (due to complicated factors) that a user of my app may attempt to open a record in a view page when the record called actually does not exist. The baked-in behavior when this occurs is the application redirects to the list page. This makes sense under normal circumstances, but in my case it just causes confusion.
What I want to happen instead is redirect the user to a different page. The problem is I'm struggling with how to code that and if there is even an event available where it would work. Ideally, I would need to be able to insert my code after the SQL is run but before the page is displayed. I have tried placing the following code in both the BeforeShowView() and ProcessValuesView() events with no luck. I think that either my test for missing page id isn't working, or the redirect occurs within the base code before these events fire.
Here's my code:
// Try to redirect to notopic page rather than list page if current page not found
string pageID = values["Page"].ToString();
if (string.IsNullOrEmpty(pageID))
{
MVCFunctions.HeaderRedirect("page","view","editid1=notopic");
}
Any ideas?