Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Code that compiles under both ASP.NET 1.1 and 2.0?

Reply
Thread Tools

Code that compiles under both ASP.NET 1.1 and 2.0?

 
 
wizofaus@hotmail.com
Guest
Posts: n/a
 
      02-06-2007
Has anyone successfully managed to work out how to get ASP pages to
compile under both 1.1 and 2.0? Basically I'm in the final stages
before deploying a version of an application that will be using 1.1,
and still making occasional fixes, but I'm also trying to move over
to .NET 2.0 for the next version. The biggest problem I've hit is the
new compilation models. From what I've read, .NET 2.0 is supposed be
able to support the old "codebehind" compilation model for .NET 1.1
that doesn't require partial classes etc., but the only way I've been
able to get it to work is to change the .aspx @page directive to use
"Src=" instead of "CodeBehind=". Without this I get a "Could not load
type 'xxx'" error for every page using Codebehind. But doing this
causes it fail with strange runtime errors under .NET 1.1 (mainly to
do with types being defined in multiple places).
The other alternative was use wrap the "partial" keyword, plus the
page control variable definitions not needed under .NET 2.0 in an #if,
and have both the "Codebehind" AND "Codefile" directives in the ASPX
pages - .NET 2.0 appears to ignore the former, and .NET 1.1 the
latter, so I believe this will actually work, but I'm not 100%
confident by any means, and it sure looks ugly having code like:

public
#if NET20
partial
#endif
class MyPage : System.Web.UI.Page
{
#if !NET20
public TextBox TextBox1;
public TextBox TextBox2;
#endif
}

all over the place!

Then there's the issue of code that needs to be in the App_Code
directory...although I can deal with that via the Source Control
system relatively easily.

I expect to be fixing bugs in the 1.1 version for at least a few weeks
yet, and having to continally manually apply them to the 2.0 version
seems theoretically more painful than trying to stick with a single
code version (note that I'm not planning on making functionality
changes to the 2.0 version for a while, otherwise obviously I would
need two code branches), but I suspect that MS haven't exactly made
this easy to achieve, for whatever reason.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-06-2007
If you want more interoperability between 1.1 and 2.O, use the Web
Application Project model instead of the original WebSite model in ASP.NET
2.0.
99% of 1.1 code WILL compile just fine in .NET 2.0.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"(E-Mail Removed)" wrote:

> Has anyone successfully managed to work out how to get ASP pages to
> compile under both 1.1 and 2.0? Basically I'm in the final stages
> before deploying a version of an application that will be using 1.1,
> and still making occasional fixes, but I'm also trying to move over
> to .NET 2.0 for the next version. The biggest problem I've hit is the
> new compilation models. From what I've read, .NET 2.0 is supposed be
> able to support the old "codebehind" compilation model for .NET 1.1
> that doesn't require partial classes etc., but the only way I've been
> able to get it to work is to change the .aspx @page directive to use
> "Src=" instead of "CodeBehind=". Without this I get a "Could not load
> type 'xxx'" error for every page using Codebehind. But doing this
> causes it fail with strange runtime errors under .NET 1.1 (mainly to
> do with types being defined in multiple places).
> The other alternative was use wrap the "partial" keyword, plus the
> page control variable definitions not needed under .NET 2.0 in an #if,
> and have both the "Codebehind" AND "Codefile" directives in the ASPX
> pages - .NET 2.0 appears to ignore the former, and .NET 1.1 the
> latter, so I believe this will actually work, but I'm not 100%
> confident by any means, and it sure looks ugly having code like:
>
> public
> #if NET20
> partial
> #endif
> class MyPage : System.Web.UI.Page
> {
> #if !NET20
> public TextBox TextBox1;
> public TextBox TextBox2;
> #endif
> }
>
> all over the place!
>
> Then there's the issue of code that needs to be in the App_Code
> directory...although I can deal with that via the Source Control
> system relatively easily.
>
> I expect to be fixing bugs in the 1.1 version for at least a few weeks
> yet, and having to continally manually apply them to the 2.0 version
> seems theoretically more painful than trying to stick with a single
> code version (note that I'm not planning on making functionality
> changes to the 2.0 version for a while, otherwise obviously I would
> need two code branches), but I suspect that MS haven't exactly made
> this easy to achieve, for whatever reason.
>
>

 
Reply With Quote
 
 
 
 
wizofaus@hotmail.com
Guest
Posts: n/a
 
      02-06-2007
On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]
<(E-Mail Removed)> wrote:
> If you want more interoperability between 1.1 and 2.O, use the Web
> Application Project model instead of the original WebSite model in ASP.NET
> 2.0.
> 99% of 1.1 code WILL compile just fine in .NET 2.0.
> Peter
>

Sounds exactly like what I want. I'm just installing SP1 now
actually, which apparently includes it. I take it there are no real
disadvantages to using this, given I'm quite happy with the .NET 1.1
compilation model for my particular project?

 
Reply With Quote
 
wizofaus@hotmail.com
Guest
Posts: n/a
 
      02-06-2007
On Feb 6, 2:10 pm, (E-Mail Removed) wrote:
> On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]<(E-Mail Removed)> wrote:
> > If you want more interoperability between 1.1 and 2.O, use the Web
> > Application Project model instead of the original WebSite model in ASP.NET
> > 2.0.
> > 99% of 1.1 code WILL compile just fine in .NET 2.0.
> > Peter

>
> Sounds exactly like what I want. I'm just installing SP1 now
> actually, which apparently includes it. I take it there are no real
> disadvantages to using this, given I'm quite happy with the .NET 1.1
> compilation model for my particular project?


I did hit two minor issues...one was that it wasn't copying my CSS
files to the deployment location (I had to mark them explicitly to be
copied), and the other was that when debugging under VS.NET 2005 it
apparently always uses NTLM authentication, which was causing problems
with my own authentication code (I was prematurely checking for the
LOGON_USER server variable), but both problems were easily fixable,
and it all seems to be working fine. Pleasantly surprised that MS
apparently saw the need to make the upgrade path from 2003 somewhat
simpler!

 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-06-2007
Heh. Actually they didn't see the need until after VS 2005 was out and
developers started screaming bloody hell.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"(E-Mail Removed)" wrote:

> On Feb 6, 2:10 pm, (E-Mail Removed) wrote:
> > On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]<(E-Mail Removed)> wrote:
> > > If you want more interoperability between 1.1 and 2.O, use the Web
> > > Application Project model instead of the original WebSite model in ASP.NET
> > > 2.0.
> > > 99% of 1.1 code WILL compile just fine in .NET 2.0.
> > > Peter

> >
> > Sounds exactly like what I want. I'm just installing SP1 now
> > actually, which apparently includes it. I take it there are no real
> > disadvantages to using this, given I'm quite happy with the .NET 1.1
> > compilation model for my particular project?

>
> I did hit two minor issues...one was that it wasn't copying my CSS
> files to the deployment location (I had to mark them explicitly to be
> copied), and the other was that when debugging under VS.NET 2005 it
> apparently always uses NTLM authentication, which was causing problems
> with my own authentication code (I was prematurely checking for the
> LOGON_USER server variable), but both problems were easily fixable,
> and it all seems to be working fine. Pleasantly surprised that MS
> apparently saw the need to make the upgrade path from 2003 somewhat
> simpler!
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
How do I add exception-handling to this code and make sure it compiles and runs properly? robinsand@gmail.com C++ 4 06-20-2006 09:13 PM
code that compiles in c but not in c++? al.cpwn@gmail.com C Programming 7 04-03-2006 03:35 AM
Visual Studio Compiles when Bad Code Exists (c#) bholland ASP .Net 2 02-02-2006 02:48 AM
Why does the following code compiles ? Razvan Java 3 09-20-2004 04:18 PM



Advertisments