0

I moved three .ASPX files with their associated .cs and .designer.cs files to a different folder, and changed their names. When I tried to recompile, I got the message above for 5-6 different .ASPX files, including the three that I moved. The line number in the .ASPX file was always near the top (line 10-20 or so), but on different tags each time. I also got about 250 other messages on .cs files, saying all the controls in many (perhaps all) .ASPX files do not exist.

Most articles I found about this message involved different versions of MVC, but this is not an MVC app. I did try tweaking the NuGet settings, and tried commenting out the reference in web.config to System.Web.Optimization, both without success.

I also tried excluding the offending .ASPX files from the project and re-including them. This caused the message to go away for that file, but when I excluded the last file, the same message appeared on another file, usually the next one in the project.

EDIT: Answers to several other questions address adding a missing reference, but the reference is already there in my case.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Jim S
  • 1,069
  • 3
  • 10
  • 17
  • Possible duplicate of [How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app](http://stackoverflow.com/questions/9475893/how-to-add-reference-to-system-web-optimization-for-mvc-3-converted-to-4-app) (which is for MVC, but the same package is used nonetheless) – mason Dec 05 '15 at 01:21

2 Answers2

1

When you create page first time, it taking it's folder, relation each to other, and making link in this pages. Never share .aspx and .aspx.cs for different folders. If you think, that your .aspx.cs file is too big, just move to some class (for example, App_Code/MyClass), and just call that class from your .aspx.cs file. If you need correct moving, just create new .aspx page in the destination folder, and then copy code from old page to a new, and delete old page. It is best way to prevent (in your case to solve) errors

Khazratbek
  • 1,656
  • 2
  • 10
  • 17
  • Thank you Khazratbek. That helpted a lot. Recreating the three moved items using Visual Studio got rid of the message that 'Optimization' does not exist in the namespace. However, I still have the 250 other messages. Perhaps I've damaged the project somehow. Do you have any suggestion about that? I don't want to recreate the whole project unless I have to, because there are is a lot of Entity Framework info that would have to be recreated manually. – Jim S Dec 05 '15 at 15:31
0

I solved the problem by restoring the project from source control, and then following Khazratbek's advice. I created the three new pages in the new location, and copied only the contents of the old files.

Jim S
  • 1,069
  • 3
  • 10
  • 17