Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > WebAppication project doesn't like separate codefiles

Reply
Thread Tools

WebAppication project doesn't like separate codefiles

 
 
cmrchs@gmail.com
Guest
Posts: n/a
 
      08-02-2008
On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "Juan T. Llibre" <nomailrepl...@nowhere.com> wrote in messagenews:. ..
>
> > VS 2008 follows this type of class naming syntax in code-behind files:

>
> > In default.aspx.cs, the code-behind page for Default.aspx...
> > public partial class _Default : System.Web.UI.Page

>
> > Notice the underscore, and notice that the page's class
> > is named for the page name, with an underscore added.

>
> Also, the upper-case "D", C# being case-sensitive...
>
> > It looks to me like like renamed an aspx page, but did not change the
> > class name in the code-behind.

>
> Indeed. I've been caught out with that on more than one occasion...
>
> > The IDE does not automatically change the class name for you if you rename
> > a file.
> > If you ask me, I think it should...

>
> I agree or, at the very least, pop a warning to say that there is now a
> "mismatch" (for want of a better term) between the class name specified in
> the page's @Page directive and the actual partial class specified in its
> associated code-behind file...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


no difference

There was no namespace so it wasn't necessary but I've defined the
class in a namespace now

namespace MyNs
{
public partial class WebForm1 : System.Web.UI.Page
{
}
}

Inherits="MyNs.WebForm1"

but still nothing

anyway ... as the best design still is a separate controlLib for each
tier-component I think I'll leave it at that. unless you have another
option ?

i was just curious about this App_Code thing but as you can imagine,
I'm not impressed at all by that functionality..
my experience with it? a waste of time.
what is supposed the benefit of it?
I can only use my product-class when using it in inline script in the
aspx-file, so why come up then with the idea of code-behind in the
first place?

Chris
 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      08-02-2008
re:
!> i was just curious about this App_Code thing but as you can imagine,
!> I'm not impressed at all by that functionality..

Quite frankly, I'm not too impressed with it, either, primarily from a security viewpoint.
Uploading raw code to a server isn't a very secure approach to programming.

Also, there's no problems like the one you're encountering.

re:
!> I can only use my product-class when using it in inline script in the aspx-file,
!> so why come up then with the idea of code-behind in the first place?

I've evolved a personal preference which skirts the issues :

I compile assemblies with my helper classes ( my DAL layer ) from the command-line,
and place the resulting assembly in the /bin directory.

It's quite easy then to import my namespace with

<%@ Import Namespace="DataObjects" %>

....and instantiating the SQLDATA class is uncomplicated with :

Dim RS as New SQLDATA()

It works 100% of the time with no fuss.

I'd recommend ( depending on your time availability )
you dump what you're doing now...and create your own Data Access Layer (DAL).

Here's two pages with sample code which will help you get that done quickly :

http://msdn.microsoft.com/en-us/library/aa581778.aspx

http://weblogs.asp.net/scottgu/archi...15/435498.aspx




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
<> wrote in message news:473ffac9-7aa3-4d08-a827-...
> On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
>> "Juan T. Llibre" <nomailrepl...@nowhere.com> wrote in messagenews:. ..
>>
>> > VS 2008 follows this type of class naming syntax in code-behind files:

>>
>> > In default.aspx.cs, the code-behind page for Default.aspx...
>> > public partial class _Default : System.Web.UI.Page

>>
>> > Notice the underscore, and notice that the page's class
>> > is named for the page name, with an underscore added.

>>
>> Also, the upper-case "D", C# being case-sensitive...
>>
>> > It looks to me like like renamed an aspx page, but did not change the
>> > class name in the code-behind.

>>
>> Indeed. I've been caught out with that on more than one occasion...
>>
>> > The IDE does not automatically change the class name for you if you rename
>> > a file.
>> > If you ask me, I think it should...

>>
>> I agree or, at the very least, pop a warning to say that there is now a
>> "mismatch" (for want of a better term) between the class name specified in
>> the page's @Page directive and the actual partial class specified in its
>> associated code-behind file...
>>
>> --
>> Mark Rae
>> ASP.NET MVPhttp://www.markrae.net

>
> no difference
>
> There was no namespace so it wasn't necessary but I've defined the
> class in a namespace now
>
> namespace MyNs
> {
> public partial class WebForm1 : System.Web.UI.Page
> {
> }
> }
>
> Inherits="MyNs.WebForm1"
>
> but still nothing
>
> anyway ... as the best design still is a separate controlLib for each
> tier-component I think I'll leave it at that. unless you have another
> option ?
>
> i was just curious about this App_Code thing but as you can imagine,
> I'm not impressed at all by that functionality..
> my experience with it? a waste of time.
> what is supposed the benefit of it?
> I can only use my product-class when using it in inline script in the
> aspx-file, so why come up then with the idea of code-behind in the
> first place?
>
> Chris



 
Reply With Quote
 
 
 
 
cmrchs@gmail.com
Guest
Posts: n/a
 
      08-02-2008
On Aug 2, 4:55 pm, "Juan T. Llibre" <nomailrepl...@nowhere.com> wrote:
> re:
> !> i was just curious about this App_Code thing but as you can imagine,
> !> I'm not impressed at all by that functionality..
>
> Quite frankly, I'm not too impressed with it, either, primarily from a security viewpoint.
> Uploading raw code to a server isn't a very secure approach to programming.
>
> Also, there's no problems like the one you're encountering.
>
> re:
> !> I can only use my product-class when using it in inline script in the aspx-file,
> !> so why come up then with the idea of code-behind in the first place?
>
> I've evolved a personal preference which skirts the issues :
>
> I compile assemblies with my helper classes ( my DAL layer ) from the command-line,
> and place the resulting assembly in the /bin directory.
>
> It's quite easy then to import my namespace with
>
> <%@ Import Namespace="DataObjects" %>
>
> ...and instantiating the SQLDATA class is uncomplicated with :
>
> Dim RS as New SQLDATA()
>
> It works 100% of the time with no fuss.
>
> I'd recommend ( depending on your time availability )
> you dump what you're doing now...and create your own Data Access Layer (DAL).
>
> Here's two pages with sample code which will help you get that done quickly :
>
> http://msdn.microsoft.com/en-us/library/aa581778.aspx
>
> http://weblogs.asp.net/scottgu/archi...15/435498.aspx
>
> Juan T. Llibre, asp.net MVP
> asp.net faq :http://asp.net.do/faq/
> foros de asp.net, en espaņol :http://asp.net.do/foros/
> ======================================
>
> <cmr...@gmail.com> wrote in messagenews:473ffac9-7aa3-4d08-a827-...
> > On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> >> "Juan T. Llibre" <nomailrepl...@nowhere.com> wrote in messagenews:. ..

>
> >> > VS 2008 follows this type of class naming syntax in code-behind files:

>
> >> > In default.aspx.cs, the code-behind page for Default.aspx...
> >> > public partial class _Default : System.Web.UI.Page

>
> >> > Notice the underscore, and notice that the page's class
> >> > is named for the page name, with an underscore added.

>
> >> Also, the upper-case "D", C# being case-sensitive...

>
> >> > It looks to me like like renamed an aspx page, but did not change the
> >> > class name in the code-behind.

>
> >> Indeed. I've been caught out with that on more than one occasion...

>
> >> > The IDE does not automatically change the class name for you if you rename
> >> > a file.
> >> > If you ask me, I think it should...

>
> >> I agree or, at the very least, pop a warning to say that there is now a
> >> "mismatch" (for want of a better term) between the class name specified in
> >> the page's @Page directive and the actual partial class specified in its
> >> associated code-behind file...

>
> >> --
> >> Mark Rae
> >> ASP.NET MVPhttp://www.markrae.net

>
> > no difference

>
> > There was no namespace so it wasn't necessary but I've defined the
> > class in a namespace now

>
> > namespace MyNs
> > {
> > public partial class WebForm1 : System.Web.UI.Page
> > {
> > }
> > }

>
> > Inherits="MyNs.WebForm1"

>
> > but still nothing

>
> > anyway ... as the best design still is a separate controlLib for each
> > tier-component I think I'll leave it at that. unless you have another
> > option ?

>
> > i was just curious about this App_Code thing but as you can imagine,
> > I'm not impressed at all by that functionality..
> > my experience with it? a waste of time.
> > what is supposed the benefit of it?
> > I can only use my product-class when using it in inline script in the
> > aspx-file, so why come up then with the idea of code-behind in the
> > first place?

>
> > Chris


thank you!

Chris
 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      08-04-2008
"Juan T. Llibre" <> wrote in message
news:O%238CC$...
> re:
> !> i was just curious about this App_Code thing but as you can imagine,
> !> I'm not impressed at all by that functionality..
>
> Quite frankly, I'm not too impressed with it, either, primarily from a

security viewpoint.
> Uploading raw code to a server isn't a very secure approach to

programming.
>
> Also, there's no problems like the one you're encountering.
>
> re:
> !> I can only use my product-class when using it in inline script in the

aspx-file,
> !> so why come up then with the idea of code-behind in the first place?
>
> I've evolved a personal preference which skirts the issues :
>
> I compile assemblies with my helper classes ( my DAL layer ) from the

command-line,
> and place the resulting assembly in the /bin directory.
>
> It's quite easy then to import my namespace with
>
> <%@ Import Namespace="DataObjects" %>
>
> ...and instantiating the SQLDATA class is uncomplicated with :
>
> Dim RS as New SQLDATA()
>
> It works 100% of the time with no fuss.
>
> I'd recommend ( depending on your time availability )
> you dump what you're doing now...and create your own Data Access Layer

(DAL).
>
> Here's two pages with sample code which will help you get that done

quickly :
>
> http://msdn.microsoft.com/en-us/library/aa581778.aspx
>
> http://weblogs.asp.net/scottgu/archi...15/435498.aspx
>
>


Can't say I've ever seen these problems myself. App_Code has always worked
IMO experience and thats across quite a number of clients. Unless you are
being really fussy with strong names etc being App_Code is no less secure
than the bin directory. I don't put any of my code there myself but
customers use it. Its easy and 'fudgeable' (there is no need to build dlls
to make a minor tweak).

So far I have found the code that starts off in App_Code migrates to the bin
once it has been established.

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      08-05-2008
re:
!> App_Code is no less secure than the bin directory

I'll take a strong exception to that...

re:
!> I don't put any of my code there myself

Why ?

re:
!> So far I have found the code that starts off in App_Code
!> migrates to the bin once it has been established.

Sure, it does, but your source code also stays in App_Code
where any two-bit programmer in your organization can see it.

I prefer to not upload source code...and obfuscate my assemblies.
Ymmv...




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"Anthony Jones" <> wrote in message news:...
> "Juan T. Llibre" <> wrote in message
> news:O%238CC$...
>> re:
>> !> i was just curious about this App_Code thing but as you can imagine,
>> !> I'm not impressed at all by that functionality..
>>
>> Quite frankly, I'm not too impressed with it, either, primarily from a

> security viewpoint.
>> Uploading raw code to a server isn't a very secure approach to

> programming.
>>
>> Also, there's no problems like the one you're encountering.
>>
>> re:
>> !> I can only use my product-class when using it in inline script in the

> aspx-file,
>> !> so why come up then with the idea of code-behind in the first place?
>>
>> I've evolved a personal preference which skirts the issues :
>>
>> I compile assemblies with my helper classes ( my DAL layer ) from the

> command-line,
>> and place the resulting assembly in the /bin directory.
>>
>> It's quite easy then to import my namespace with
>>
>> <%@ Import Namespace="DataObjects" %>
>>
>> ...and instantiating the SQLDATA class is uncomplicated with :
>>
>> Dim RS as New SQLDATA()
>>
>> It works 100% of the time with no fuss.
>>
>> I'd recommend ( depending on your time availability )
>> you dump what you're doing now...and create your own Data Access Layer

> (DAL).
>>
>> Here's two pages with sample code which will help you get that done

> quickly :
>>
>> http://msdn.microsoft.com/en-us/library/aa581778.aspx
>>
>> http://weblogs.asp.net/scottgu/archi...15/435498.aspx
>>
>>

>
> Can't say I've ever seen these problems myself. App_Code has always worked
> IMO experience and thats across quite a number of clients. Unless you are
> being really fussy with strong names etc being App_Code is no less secure
> than the bin directory. I don't put any of my code there myself but
> customers use it. Its easy and 'fudgeable' (there is no need to build dlls
> to make a minor tweak).
>
> So far I have found the code that starts off in App_Code migrates to the bin
> once it has been established.
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>



 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      08-06-2008
"Juan T. Llibre" <> wrote in message
news:...
> re:
> !> App_Code is no less secure than the bin directory
>
> I'll take a strong exception to that...


Why? Do you think it isn't true?

>
> re:
> !> I don't put any of my code there myself
>
> Why ?


I just don't

>
> re:
> !> So far I have found the code that starts off in App_Code
> !> migrates to the bin once it has been established.
>
> Sure, it does, but your source code also stays in App_Code
> where any two-bit programmer in your organization can see it.
>


We don't employ two-bit programmers. Besides a two-bit programmer can still
manage to compile a dll and drop it in the bin.



--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      08-06-2008
re:
!>>> App_Code is no less secure than the bin directory
!>> I'll take a strong exception to that...
!> Why? Do you think it isn't true?

Anthony, you're rationalizing insecure procedures.

Name me *one* programmer who prefers to place raw source code
a server...and I'll show you a severely complacent person who's likely
to get the jolt of his life when his precious code is lifted.

re:
!>>> I don't put any of my code there myself
!>> Why ?
!> I just don't

So, you *do* agree with me.

re:
!> Besides a two-bit programmer can still manage to compile a dll and drop it in the bin

Where the code will be a lot safer than if uploaded raw.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"Anthony Jones" <> wrote in message news:uxN18qA%...
> "Juan T. Llibre" <> wrote in message
> news:...
>> re:
>> !> App_Code is no less secure than the bin directory
>>
>> I'll take a strong exception to that...

>
> Why? Do you think it isn't true?
>
>>
>> re:
>> !> I don't put any of my code there myself
>>
>> Why ?

>
> I just don't
>
>>
>> re:
>> !> So far I have found the code that starts off in App_Code
>> !> migrates to the bin once it has been established.
>>
>> Sure, it does, but your source code also stays in App_Code
>> where any two-bit programmer in your organization can see it.



> We don't employ two-bit programmers. Besides a two-bit programmer can still
> manage to compile a dll and drop it in the bin.




> --
> Anthony Jones - MVP ASP/ASP.NET
>
>



 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      08-08-2008
"Juan T. Llibre" <> wrote in message
news:%237p$HOB%...
> re:
> !>>> App_Code is no less secure than the bin directory
> !>> I'll take a strong exception to that...
> !> Why? Do you think it isn't true?
>
> Anthony, you're rationalizing insecure procedures.
>
> Name me *one* programmer who prefers to place raw source code
> a server...and I'll show you a severely complacent person who's likely
> to get the jolt of his life when his precious code is lifted.
>
> re:
> !>>> I don't put any of my code there myself
> !>> Why ?
> !> I just don't
>
> So, you *do* agree with me.
>
> re:
> !> Besides a two-bit programmer can still manage to compile a dll and drop

it in the bin
>
> Where the code will be a lot safer than if uploaded raw.
>


I think we're talking at cross purposes. I hadn't considered that by
security you were refering to protecting your source code as an asset. I
was thinking of security in terms of a black hat doing something malicious
to site. If such a person has access to the App_Code they have access to
the bin and in fact the whole site.

Still there are times when source isn't particularly valueable as an asset
and its accessibility to customers (by customer I mean duely authorised
personnel who are employed by the organisation that commissioned the work)
has value.



--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      08-08-2008
re:
!> I hadn't considered that by security you were
!> referring to protecting your source code as an asset.

Yes, I was.

re:
!> Still there are times when source isn't particularly valueable as an asset

Yes, there are such times.

For application developers who deploy their apps to their client's servers,
though, ( and there's tons of those ), it's far better for them not to deploy
raw code to the App_Code directory.

Otherwise, they're just giving their knowledge away to cut-and-paste ops.






Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"Anthony Jones" <> wrote in message news:%23t832MV%...
> "Juan T. Llibre" <> wrote in message
> news:%237p$HOB%...
>> re:
>> !>>> App_Code is no less secure than the bin directory
>> !>> I'll take a strong exception to that...
>> !> Why? Do you think it isn't true?
>>
>> Anthony, you're rationalizing insecure procedures.
>>
>> Name me *one* programmer who prefers to place raw source code
>> a server...and I'll show you a severely complacent person who's likely
>> to get the jolt of his life when his precious code is lifted.
>>
>> re:
>> !>>> I don't put any of my code there myself
>> !>> Why ?
>> !> I just don't
>>
>> So, you *do* agree with me.
>>
>> re:
>> !> Besides a two-bit programmer can still manage to compile a dll and drop

> it in the bin
>>
>> Where the code will be a lot safer than if uploaded raw.



> I think we're talking at cross purposes. I hadn't considered that by
> security you were refering to protecting your source code as an asset. I
> was thinking of security in terms of a black hat doing something malicious
> to site. If such a person has access to the App_Code they have access to
> the bin and in fact the whole site.
>
> Still there are times when source isn't particularly valueable as an asset
> and its accessibility to customers (by customer I mean duely authorised
> personnel who are employed by the organisation that commissioned the work)
> has value.
>
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>



 
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
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:27 AM
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:26 AM
Using separate classpaths for separate classes? Frank Fredstone Java 1 06-27-2006 06:46 AM
object-like macro used like function-like macro Patrick Kowalzick C++ 5 03-14-2006 03:30 PM
How to use several separate classes (separate files) to be executed in one class (another file) EvgueniB Java 1 12-15-2003 01:18 AM



Advertisments