IsPostback = false, although Request.HttpMethod is "POST"?

I recently hacked into web forms, seeing if one of my (routing) projects could be used with it. So far it has been nothing more than a nuisance, but I am almost to the point that it "works"

I made the page "Test.aspx". In Global.asax, I made it so that it /Test.aspx /test instead of /Test.aspx . It works completely. It goes off the user page class. The custom class finds the HtmlForms on the page and overwrites its Action attribute with the corresponding value: /test .

Now I hit a huge brick wall called Viewstate and ASP.Net. I added the Test.aspx button with the OnClick handler. I can click a button and the page will be back, etc., but the OnClick event will not happen. I don’t understand how simply changing the URL can break the viewstate this way, since I didn’t have the impression that the Viewstate would track such a thing. In addition, IsPostback will be false, although HttpMethod == true. That makes no sense to me.

In addition, I turned off EventValidation because I realized that this would be a problem, but this problem persists.

How can I make viewstate and postbacks work as usual when rewriting URLs?

(Please note: my URL rewrite form does all internal rewriting, the HTTP address is never redirected to the user)

+4
source share
2 answers

You may need to tell HttpContext that the URL will also be rewritten.

Try to do something like this:

 HttpContext.Current.RewritePath("/test"); 
0
source

IsPostBack is used to check if a request is being run out of control of the page itself.

And HttpMethod is used to check the type of request.

0
source

Source: https://habr.com/ru/post/1345181/


All Articles