ViewState in a HttpHandler?
I have an aspx page that I want to convert to an HttpHandler
, but I'm struggling with ViewState
that's been 开发者_JAVA技巧used in the code behind of the aspx page. How do you solve this?
If your page relies on ViewState it's probably not a good candidate for an HttpHandler. ViewState is used to persist values of controls between postbacks. Handlers should be stateless and not depend on postbacks.
Viewstate is rendered to the client as a hidden form field. You can emulate Viewstate by rendering an <Input Type="Hidden"
tag to your (now manually generated?) html.
Like Darin says though, it's better to either make your response stateless, or leave it as a Page
精彩评论