By putting common code in the ascx it allows two aspx files to share
that code without having to modify the contents of App_Code.
Modifying the contents of App_Code or modifying /bin results in the
Session being reset for all users (for "in-process" sessions).
However this is not the case if you modify just the ascx on the server
since it gets JIT compiled anyway.  So, for example, if some users are
using an application that depends on Session, and another user is
using another application which he reports as broken, then using this
work-around, you could update the second application without affecting
the first application.

On Feb 4, 2:38 am, Cerebrus <[email protected]> wrote:
> Can you explain why you need to recompile and update DLLs or class
> files repeatedly during production server uptimes ?
>
> On Feb 4, 12:37 am, jay <[email protected]> wrote:
>
>
>
> > So if I include a .cs file inside App_Code I can access this class
> > from a aspx file without compiling? This is really what I am going
> > for.  If I compile and push a DLL to the /bin directory, then this
> > causes the Session to be lost, which is undesirable.  The alternative
> > is to run the Session differently, but I've read that that causes
> > Session to be slower.
>
> > On Feb 3, 2:13 pm, Cerebrus <[email protected]> wrote:
>
> > > Ummm... App_Code does not contain DLLs.
>
> > > On Feb 3, 9:58 pm, jay <[email protected]> wrote:
>
> > > > I figured out I can do this:
>
> > > > ---file1.ascx
> > > > <script runat="server">
> > > >     public int data;
> > > > </script>
>
> > > > ---file2.aspx
> > > > <%@ Page Language="C#" AutoEventWireup="true" %>
> > > > <%@ Register TagPrefix="uc1" TagName="inc" Src="file1.ascx" %>
> > > > <uc1:inc id="ascx" runat="server"></uc1:inc>
> > > > <script runat="server">
> > > > protected void Page_Load( object sender, EventArgs e )
> > > > {
> > > >     ascx.data = 1;}
>
> > > > </script>
>
> > > > ...which is good enough for me.. gets me basic code re-use without
> > > > having to worry about session getting reset by pushing DLLs..
>
> > > > On Feb 3, 11:51 am, Cerebrus <[email protected]> wrote:
>
> > > > > I strongly doubt it. In any case, shared code should be in a shared
> > > > > location... say, App_Code.
>
> > > > > On Feb 3, 8:26 pm, jay <[email protected]> wrote:
>
> > > > > > Is it possible to share code between 2 ASPX files that do not have a
> > > > > > codebehind? For example, something like this:
>
> > > > > > ---file1.aspx
> > > > > > <%@ Page Language="C#" AutoEventWireup="true" %>
> > > > > > <script runat="server">
> > > > > > namespace blah
> > > > > > {
> > > > > > public int data;}
>
> > > > > > </script>
>
> > > > > > ---file2.aspx
> > > > > > <%@ Page Language="C#" AutoEventWireup="true" %>
> > > > > > <%@ Import Namespace="blah" %>
> > > > > > <script runat="server">
> > > > > > protected void Page_Load( object sender, EventArgs e )
> > > > > > {
> > > > > >     data = 1;}
>
> > > > > > </script>- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Reply via email to