General discussion
-
Topic
-
ASP.NET Equivalent of Server-Side Includes?
LockedMy company’s website is already ASP-based, but we are creating new pages in ASP.NET where it makes sense. But I’m having trouble coding the .NET pages to work with the old ASP pages due to the fact that .NET doesn’t support server-side includes. Let me explain:
In the part of the website where users have logged in, we are storing a very few pieces of data in session variables, then referencing them as needed on each page. Each page includes an INC file that contains code to check a particular session variable, and if it’s not populated because the user hasn’t logged in or his session has expired, direct him to the appropriate “session expired” notice page. If it is populated, a series of other variables (Dim’d in the INC file and referenced later in each page) are populated according to the contents of another session variable.
How do I accomplish the same thing in ASP.NET? I could put this into a custom code snippet, but while that’s nice for when I first create a new page, it’s taking one step backwards as far as code reuse and ease of maintenance goes.
Or, I could rework this as a class and make those INC variable as properties of the class, but classes can’t directly access session variables, meaning I can’t populate the properties in the New constructor. So I’d have to duplicate code in each page that uses the class to populate those properties in the Page_Load sub, and now I’ve got a different set of ease-of-maintenance issues.
There has to be another way to do this in .NET. Isn’t there?