Why are changes in code reflected in an ASP.NET website even if the code does not compile?
Asked Answered
R

1

0

I am working on a rather large website project in Visual Studio 2010 and I'm wondering why changes in the code are reflected when I test a web page individually (by right-clicking the .aspx file and selecting View Changes in Browser), even though there are errors in the code that prevent it from compiling. This confuses me. I am getting several errors when I run the code in Visual Studio. However, any change that I make, either in the client side code or the server side code, is reflected if I just view the page in the browser. This makes sense for client side code and markup, but why does it even take the "flawed" server side code? Doesn't server side code need to be compiled? Thanks for any input. I have many more questions on this topic, but I'm hoping the answer to this question helps me answer the other questions I have.

EDIT: Further information on the errors I'm getting

I have learned some more details from the original developer assigned to this project. He has informed me that, for every additional feature that he built in to the project, he copied and pasted the original project directory and renamed the folder. For instance, this is the original project directory:

App_Code [folder]

App_Data [folder]

Web.config [file]

...

He copied this every time he built a new "module" into the website. This is certainly not the way that I would have done it, but it has already been done now. As it stands, there are 4 copies of this original project directory, which means there are 4 web.config files, 4 App_Code and App_Data folders (and 4 copies of the classes in the App_Code folder). The errors I'm getting are things like these: [server control] is not declared. It may be inaccessible due to its protection level, and [server control] is not a member of [partial class], among a few others that would certainly alert intellisense if they were, in fact, errors. It seems that, for some reason, the server controls on each of my webpages are not correctly linked to the corresponding code-behind file. But intellisense does not highlight these errors or acknowledge them in any way. I get these errors when I try to build the project. I have tried to expose the designer code file to try to fix these errors manually, but I learned that you cannot do that in a Website project. I am honestly at a loss.

If anyone has any idea how to fix this, please let me know. If I can be more clear, please tell me. I can't include any actual code, but I can try to give you some examples if that would help.

Here is another question that seems to be similar to mine. Even the number of errors that Visual Studio reported is the same. variable is not declared it may be inaccessible due to its protection level

Rina answered 25/4, 2016 at 17:8 Comment(11)
Is your Visual Studio's Configuration Manager set to compile the website code files when you press F5? Is the compilation error you mention in the file you are working on or a different file?Solemnity
I don't believe the server side code is updated. I mean, if the vb.net code does not compile, then it does not compile. Nothing stops you from saving the source code, but if the code does not compile, then it cannot possible be saved! - as you note markup etc. is saved, but vb.net code can also be saved and most certainly will be. However if such server code does not compile, then it don't compile - that fact has VERY little to do with the code not being saved. And the only compiling we talking about is vb.net code, since everything else is runtime.Stodge
@AlbertD.Kallal I completely agree. I think the errors I'm getting in the code when I try to compile it are erroneous themselves. I don't know why, but it says that all of the server controls that I put on the pages are inaccessible due to their protection level, and, thus, the code does not compile. However, it worked just fine when I was right-clicking and viewing the page in the browser. It just refuses to run.Rina
@Solemnity The errors I'm getting are in the file that I'm working on and in other files. It only happens when I try to run the code. It has worked every time I just right-click and view the changes in the browser. I don't have a clue why this is happening.Rina
You can launch a project without pre-compiling. Does this error occur when the Configuration Manager is set to not compile on build? Also, can you provide a sample so I can replicate this?Solemnity
@Solemnity I have updated the question. Maybe this will provide some information that will help us solve this problem.Rina
I'm a bit confused... how can you have four App_Code directories? Windows will not allow duplicated file or folder names.Solemnity
@Solemnity They are in different folders. In each folder, the original project directory was copied. So, in the main project directory, you have the App_Code folder, the App_Data folder, and the Web.config file. Then, in another folder in the solution, you have another App_Data, App_Code, and Web.config file. Let it be known that I did not do this. This was how the project was when it was given to me.Rina
So it sounds like this is a web application project, not a website project, is this right?Solemnity
@Solemnity It is actually a website project. I would encourage you to read over the question that I included in my question at the bottom. It's very similar, and it'll help you understand kind of what's going on with my question. I just don't think the solution to the other question will work for me.Rina
Let us continue this discussion in chat.Solemnity
R
0

It turns out that the original developer had made copies of the partial class files. They were dispersed throughout the project, so I had no idea they were there. After they were deleted, everything worked like I expected.

Rina answered 27/4, 2016 at 12:47 Comment(2)
Sorry for being a Johnny Come Lately to this question of yours, but I'm glad you got it figured out.Ancel
@jp2code Thank you. The question of yours that I referred to was very helpful in understanding what was going on. I have another one if you'd like to take a look. :) https://mcmap.net/q/833276/-how-do-you-use-a-return-value-from-the-server-side-vb-net-on-the-client-side-javascript/2465664Rina

© 2022 - 2024 — McMap. All rights reserved.