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

Discussion in 'ASP .Net' started by wizofaus@hotmail.com, Feb 6, 2007.

  1. Guest

    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.
    , Feb 6, 2007
    #1
    1. Advertising

  2. 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




    "" 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.
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 6, 2007
    #2
    1. Advertising

  3. Guest

    On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]
    <> 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?
    , Feb 6, 2007
    #3
  4. Guest

    On Feb 6, 2:10 pm, wrote:
    > On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]<> 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!
    , Feb 6, 2007
    #4
  5. 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




    "" wrote:

    > On Feb 6, 2:10 pm, wrote:
    > > On Feb 6, 12:51 pm, Peter Bromberg [C# MVP]<> 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!
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 6, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amelyan
    Replies:
    4
    Views:
    455
    Juan T. Llibre
    Nov 4, 2005
  2. bholland
    Replies:
    2
    Views:
    358
    bholland
    Feb 2, 2006
  3. Julian
    Replies:
    12
    Views:
    801
    red floyd
    Dec 21, 2004
  4. Replies:
    4
    Views:
    326
    Peter
    Jun 20, 2006
  5. ABCL
    Replies:
    0
    Views:
    545
Loading...

Share This Page