简体   繁体   English

Webforms:HttpModule或HttpHandler将信息保存在缓存中

[英]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?? 我想在缓存中存储一​​些信息,以便以后与用户键入的信息进行比较。我应该使用HttpModule还是HttpHandler? Or is there any better way to do this in WebForms?? 还是在WebForms中有更好的方法呢? I know that in MVC ActionFilters can be used. 我知道在MVC中可以使用ActionFilters。

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"]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM