ASP.NET: Fix the aspx.designer.cs file when corrupted

For some reason I am coding away and inexplicably, usually when trying to update my Subversion repository, the aspx.designer.cs file that is attached to my page simply decides to ignore all my controls. Perhaps a guru who knows why could explain in the comments, and I am just ignorant. I wouldn’t argue that with you. I am writing it here for anyone else with the problem, and so I don’t forget it either.

Here is what you do:

1. Let’s say the page you’re working on is called MyPage.aspx. What you want to do then is delete the MyPage.aspx.designer.cs file, only that file, and be careful not to delete MyPage2′s file or any other.

2. Then, right-click the MyPage.aspx file (the main one with HTML/ASP in it, not the CodeBehind) and select the “Convert to Web Application” option. It should prompt you, saying something like “are you sure you want to regen those files now?” Since we just clicked that, the answer is yes. Click OK or whatever it says, and you should be back in business.

Thanks to Scott T. who taught me this trick. You saved me a ton of frustration and time. /thegeekgodsbowtoyou

, , , , , ,

Leave a Reply

You must be logged in to post a comment.