All my aspx pages are overridden with my own BasePage class. It handles logging and display of errors, among other things. I've also implemented a page template approach using custom controls that contain nested controls to paint header, menus, footer etc. The BasePage class has properties to track the display state of the page - for example, which menus to display.
What I'm currently doing in BasePage when errors occur is this:
StringWriter writer = new StringWriter();
Server.Execute("error.aspx", writer);
Response.Clear();
Response.Write(writer.ToString());
Server.ClearError();
This works fine but what I really want to do is maintain the state of the page (ie: which menus were painted when the error occurred) so the user does not lose thier current navigation.
Since I'm doing a Server.Execute the context is the same so I have all the exception information but if my error aspx page contains the same template structure as the aspx page that generated the error I get further errors about multiple controls with the same id. I think what I want to do is replace the content of my custom control in my template with the error information but am not sure how to do that.
Redirecting doesn't seem feesible because I'd lose the exception info (unless I pass stuff on the querystring).
Any ideas or other approaches?
What I'm currently doing in BasePage when errors occur is this:
StringWriter writer = new StringWriter();
Server.Execute("error.aspx", writer);
Response.Clear();
Response.Write(writer.ToString());
Server.ClearError();
This works fine but what I really want to do is maintain the state of the page (ie: which menus were painted when the error occurred) so the user does not lose thier current navigation.
Since I'm doing a Server.Execute the context is the same so I have all the exception information but if my error aspx page contains the same template structure as the aspx page that generated the error I get further errors about multiple controls with the same id. I think what I want to do is replace the content of my custom control in my template with the error information but am not sure how to do that.
Redirecting doesn't seem feesible because I'd lose the exception info (unless I pass stuff on the querystring).
Any ideas or other approaches?