I've recently begun migrating an ASP.NET project from .NET version 1.1 to 4.0. This system currently runs on customer site and works. When I migrate the solution via the VS wizard, I don't get any errors. The error is that no server control events work and the viewstate is always empty.
I've tried explicitly setting ViewStateMode
to Enabled and AutoEventWireup
to true.Unfortunately nothing works. The project is not written as a Web Application (converting does not solve the problem).
I've also check whether all server controls hav IDs set (they do).
The project has its own master page system and there is a thick layer upon System.Web.UI.Page that might break a lot of things, but so far I haven't been able to find the source of trouble.
Is there any particular setting that I should check (i.e. the default values changed since .NET 1.1) or can you give me some tips why this might happen?
EDIT 1: These are the values that get posted when clicking on a LinkButton:
CRC=-2134936892&_EVENTTARGET=MPage%24BC%24TestButton&_EVENTARGUMENT=&_VIEWSTATE=&_EVENTVALIDATION=%2FwEWAwL%2BraDpAgLB49K8AwKy8rFAt4Axk3NlUEWxrtY%2FRtaexH%2F634CkJe6G9Im5EOPXtVw%3D
EDIT 2: I've examined the custom master page mechanism closely and I found that it makes extensive use of Server.Transfer(...)
method before jumping to the right page. Is this a possible cause of the missing ViewState? (then it would be strange that the EventTarget is always persisted) And more importantly, could there have been any change between 1.1 and 4.0?
This may or may not solve the problem but if you check out this post on stack Why is the form action attribute empty on production server? it talks about a breaking change introduced in ASP.NET 3.5 sp1 centred around the action attribute of the form - it could be a place to start!
I've had to do similar things in the past and it can be a painstaking process especially when you have "custom masterpage" functionality (I've had to do the same). I'd pick a really basic page - we had a BasePage which was in herited by a CustomPage which inturn could be inherited by AdminBasePage and then Admin page etc. If you pick a relatively simple page and set a break point as early on in the process of page construction as possible and then just F10 all the way through until it renders it may show where things are being called twice (this happened a lot in our case and was the cause of some issues with values being overwrriteen etc).
In response to your server.transfer question "Edit 2" I found this resource http://www.codeproject.com/Tips/74472/ViewState-and-Server-Transfer-Best-practices which explains how to ensure (hopefully) that viewstate and server.transfer continue to work in harmony. I keep popping back to this question every day - do drop more updates as to how your getting on. You have my deepest sympathy!