views:

32

answers:

1

I'm looking for some ideas to best persist an object over multiple page requests without the use of session variables, cookies, context cache, view state or a session database.

I have a web form (ASPX) that will contain several user controls that will act as "pages", and these controls will be displayed in a one-at-a-time-manner:

<uc1:UserControl1 id="controlStep1" runat="server" visible="true" />
<uc2:UserControl2 id="controlStep2" runat="server" visible="false" />
<uc3:UserControl3 id="controlStep3" runat="server" visible="false" />

I have an object that I use to contain various parameters. These parameters come into the application as query string values and this object lazy loads them. For example:

public class Situation
{
    private string _jobId;
    private JobType _jobType;

    public string JobId
    {
        get
        {
            if (!String.IsNullOrWhitespace(_jobId))
                return _jobId;

            _jobId = GetFromQueryString("jid");    
            return _jobId;
        }
    }

    public JobType JobType
    {
        get
        {
            if (_jobType != JobType.Default)
                return _jobType;

            _jobType = GetEnumFromQueryString("jtype", typeof(JobType));
            return _jobType;
        }
    }
}

I'd like to persist this Situation object while the customer is in the web application, proceeding through a wizard-style interface as the user controls' visibilities are toggled. At the moment, I'm creating an instance of the Situation object in an HttpModule during the customer's first request and storing it in HttpContext.Current.Items, but I'd like to use lazy loading so that the various Situation object properties are only loaded as needed. However, if for example a property is accessed on controlStep1, I'd like to persist the state of the object so that if that same property is accessed on controlStep2, the getter doesn't have to go back to the query string to get the requested property's value. I could serialize the object and deserialize in an HttpModule, but if a property is accessed and loaded, it wouldn't be remembered on the next request.

Any suggestions?

+1  A: 

File system is sometimes a useful persistance mechanism.

btlog
I think this is about the only thing left (except uploading it to an FTP server or sending it by mail and retrieving it later ;-)).
Steven
@Steven, looool, I would opt for the mail solution.
Darin Dimitrov
@Steven, Thx for lightening the mood. It makes me feel like the restriction craziness isn't just in my mind :)
Bullines