views:

30

answers:

0

We have created an http module that loads data on initialize into a list, and uses that list on every endrequest event of application. However we got a null reference exception on the module at endRequest event complaining that the content is null. Yet we are sure that at module initialization we have put non-null objects correctly.

How is this possible? Any ideas?

Thanks in advance.

The place where i fill the data into the list what named as "Pages" :

using (SqlDataReader reader = cmd.ExecuteReader())
{
    while (reader.Read())
    {
        LandingPageDetails details = new LandingPageDetails();
        details.DomainId = Convert.ToInt32(reader["DomainId"]);
        details.PageId = Convert.ToInt32(reader["TrackingPageId"]);
        details.PageAddress = Convert.ToString(reader["PageAddress"]);
        if (!string.IsNullOrEmpty(details.PageAddress))
        {
            Pages.Add(details);
        }
    }
}

// Find the related record on EndRequesst event
LandingPageDetails result = Pages.Find
(
    delegate(LandingPageDetails current)
    {
        return current.PageAddress.Equals(url, StringComparison.InvariantCultureIgnoreCase);
    }
);

The line what we get the error

return current.PageAddress.Equals(url, StringComparison.InvariantCultureIgnoreCase);

"current" is the null object

P.S : It works properly, but one day later contents become null. Possibly, there is something wrong on IIS. Our server is Windows 2003, IIS 6.0