Search code examples
c#asp.netwebformshttphandlerhttpmodule

Webforms: HttpModule or HttpHandler to save info in the cache


I would like to store some information in the cache that I can compare later on with those that the user has typed in. Should I use HttpModule or HttpHandler?? Or is there any better way to do this in WebForms?? I know that in MVC ActionFilters can be used.


Solution

  • Try to use session state:

    // Save to session state in a Web Forms page class.
    Session["FirstName"] = firstName;
    Session["LastName"] = lastName;
    Session["City"] = city;
    
    // Read from session state in a Web Forms page class.
    firstName = (string)(Session["FirstName"]);
    lastName = (string)(Session["LastName"]);
    city = (string)(Session["City"]);