Web Development

General discussion


ASP.NET Equivalent of Server-Side Includes?

By Underground_In_TN ·
My 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?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

A persistent media is better for Session mgmt between heterogenous apps

by ganesh In reply to Thanks for the idea

I would recommend a file or a database to share session data rather than cookies. While it is another call to the database or fileshare, it benefits to go with anytype of data to be stored in session variables.

Collapse -

Embrace the New Paradigm

by careed In reply to ASP.NET Equivalent of Ser ...

The ASP.NET equivalent is user controls (ASCX). However, this is not a one-to-one switch. Note that ASP/VBScript is not object-oriented while ASP.NET is because .NET is. You will need to make some changes in the way you approach user controls for headers, footers, and other common sections that you have used SSIs for in the past.

Also, don't try to recreate exactly what you have in ASP to ASP.NET. This will only frustrate you. More or less, start from scratch, using your ASP page as a guide, taking full advantage of the .NET paradigm.

Related Discussions

Related Forums