Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 22, 2010 01:52 AM by smar1216
Jan 16, 2008 10:36 PM|LINK
Ok this is a little unsettling. Just recently we spent alot of time and effort converting a vs 2003 .net 1.1 project to vs 2005 .net 2.0 Web Application project with the use of the 'Convert to Web application' tool that is provided in vs 2005. There were
loads of errors and we painstakingly fixed them.
In that original conversion one of the things we researched and found we were to convert was to use CodeFile instead of Codebehind in our aspx pages because the CodeFile allowed for partial postbacks in .net 2.0 so we did. Along the way we found that the
aspx pages in our project didn't work even though we copied the compiled dll to the server. We always had to then bring the .vb files with the aspx pages or it wouldn't work; this is something we never did before the conversion.
We have now taken that project and we're using vs 2008 with the .net 3.5 framework, so today (by chance when trying to solve a different issue) I had created a new aspx page and copied it to our server along with the compiled project dll and low and behold
it failed. It said I needed to have the .vb page as well on the server for the aspx page to work. I got to looking around and changed the Codefile back to Codebehind, recompiled the project and took only the .dll to the server and it worked!!!
So, my question is what is correct? Are we supposed to be using CodeFile or Codebehind in our aspx pages? If we use Codefile we need the .vb files, and if we use Codebehind we only need the compiled .dll which is what we want. But I want to know what
is correct for .Net 3.5?
Jan 17, 2008 07:20 AM|LINK
What I know is if you create a web application in visual studio 2005, you don't need to compile to run it. You just run it like classic asp. (interpret)
But, in visual studio 2005, it also allow you to create a project. If you create a
project, you need to compile it and it will run from the compiled dll code.
Correct me if I'm wrong.
Jan 17, 2008 04:29 PM|LINK
So when we initially migrated from 1.1 to 2.0 we didn't need to use the 'Convert to Web Application' feature as that just makes it so you need the vb files and that's why it will run without compiling the code.
That is less than ideal since you are then required to maintiain the aspx page, and vb on the server instead of just the aspx page and dll file. If we change all the Codefile references back to Codebehind does this effect the partial postback abilities
in the updated .net framework?
I guess I need to know why people change this, and is it require or is it going to be the new standard for developing .Net projects. There is alot of information out there that contradics each other and I have yet to find a solid answer about it all.
Jan 18, 2008 01:17 AM|LINK
I think I don't really know how to answer your question. But I found this article -
Hope you find it useful.
Jan 18, 2008 03:51 PM|LINK
Thanks for the article, it does explain a little more about it. This issue I've raised nobody seems to know the answer to it for whatever reason. I'd like to know what other people are doing out there for their web applications.
Apr 21, 2008 08:18 AM|LINK
I had the same problem converting a VS2005 web site project to a web application. At some point I found out about the CodeFile change and religiously changed all Codebehind attributes to CodeFile. Unfortunately that was part of a bigger set of changes, so
it took me a while to find out that it'll only build and run correctly with Codebehind. I think the issue is that when VS2005 came out, it didn't cater for web applications, then MS added the support in Service Pack 1, but most of the documentation assumes
you have a web site rather than a web application, and the web application support requires the Codebehind attribute, to avoid ASP.NET creating an assembly per page on the fly, which seemed to be the problem I hit.
Apr 21, 2008 02:47 PM|LINK
Well that explains some of my problem, what was the end result for you? Did you revert all the codefile tags back to the previous codebehind?
Apr 21, 2008 03:16 PM|LINK
Yes, that's the only way I could get it to work as a web application, which is what we wanted.
Aug 10, 2008 02:51 AM|LINK
Have you been able to nail down this behavior? What standard have you adopted? I too just found this issue and Googled it and found this thread. I changed my pages back to use "codebehind" so I do not have to copy over the "cs" file. Kind of defeated the
purpse of compiling it into the DLL when using the WAP!
Aug 12, 2008 09:14 AM|LINK
All we've done is to stick to Codebehind as that works and gives the desired results. Not very scientific, but it does the job! As to the whole story, it's probably buried in MSDN somewhere, but I haven't found it and am hoping that when we move to Visual
Studio 2008 all my troubles will be solved and life will be bliss :O)