asp.net: __doPostBack not rendered sometimes

2019-05-11 20:43发布

问题:

We got strange error last days. ___doPostBack is undefined.

We are building quite advanced website, but not using postbacks much. One of place where postback used is ASP.NET Login Status control.

It is probabalystic, sometimes it is rendered, sometimes - not. For IE, Chrome it works mostly fine, but from FireFox it is quite high chance not to have doPostBack in page source.

Any ideas?

PS: In addition, error happens only on live environment, which uses Windows 2003 & IIS 5.0, dotnet framework is 3.5

Can it be because I am using OutputCache on page level?

回答1:

Yes it might be about the output cache, comment it out and try again please



回答2:

Just happened to us: When googlebot or any other bot hits your page before a regular user, the page is cached without any postback options.

We did a simple hack, using different a outputcacheprofile if the request.browser.javascript is false (asp.net sends different versions of the page to those browsers/crawlers/bots)



回答3:

I had the same problem, but I realized that ASP.NET does not render __doPostback when server controls don't need it.

When I put a gridview or linkbutton that need __doPostback, ASP.NET rendered it.



回答4:

Usually this happens when you have malformed javascript somewhere on the page (usually, before the __dopostback function).

Have you viewed the page source and looked to see if the __dopostback function is actually rendered in the page, regardless of whether you're getting the error or not?