By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,681 Members | 1,775 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,681 IT Pros & Developers. It's quick & easy.

Sharing Objects Between ASP.NET "Sites"/Projects

P: n/a
I'm developing a service which is two sites: a Mobile Site and a PC-Based
Site. The whole goal is to have them operate very similarly but, of course,
there will be many differences:

1. Web.configs will be different to handle cookieless vs. cookied Sessions
2. Mobile site will have no Master Pages (unfortunately)
3. Design of pages will be VASTLY different

However, many elements will be exactly the same:
a. I'll use most of the same classes for data access and other business
objects
b. The database in the backend is the same database

Here's my question: What's the best strategy for building these sites to
share code that's the same? It seems that in order to have two different
Web.comfigs (which I think I *must* have to support the differences between
Mobile and PC stuff), I must basically have two different sites. If I have
two different sites, I must have two different "App_Code" directories. This
means, I think, that I cannot share the same class files between the two
sites and must make copies of them. This seems like a shame.

Is there a better way to do all this?

Thanks for your help.

Alex
Jun 3 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
you should create 2 sites (web projects) and 1 library project, that is
referenced from both sites. put all shared code in the library project.
you can create one solution for all of this.

you could also just use one site and auto detect on session cookie. but
above is probably better.

-- bruce (sqlwork.com)

Alex Maghen wrote:
I'm developing a service which is two sites: a Mobile Site and a PC-Based
Site. The whole goal is to have them operate very similarly but, of course,
there will be many differences:

1. Web.configs will be different to handle cookieless vs. cookied Sessions
2. Mobile site will have no Master Pages (unfortunately)
3. Design of pages will be VASTLY different

However, many elements will be exactly the same:
a. I'll use most of the same classes for data access and other business
objects
b. The database in the backend is the same database

Here's my question: What's the best strategy for building these sites to
share code that's the same? It seems that in order to have two different
Web.comfigs (which I think I *must* have to support the differences between
Mobile and PC stuff), I must basically have two different sites. If I have
two different sites, I must have two different "App_Code" directories. This
means, I think, that I cannot share the same class files between the two
sites and must make copies of them. This seems like a shame.

Is there a better way to do all this?

Thanks for your help.

Alex
Jun 4 '07 #2

P: n/a
Bruce -

Thanks. This is *very* helpful. You mean a "Class Library" project, right?
That does make sense. Just one question: I *do* suppose that that mean that
the nice, automatic compilation business that you get when you put your .cs's
inside the App_Code directory won't happen, right? Still, it's better than
the awful copying that I've been doing.

Alex

"bruce barker" wrote:
you should create 2 sites (web projects) and 1 library project, that is
referenced from both sites. put all shared code in the library project.
you can create one solution for all of this.

you could also just use one site and auto detect on session cookie. but
above is probably better.

-- bruce (sqlwork.com)

Alex Maghen wrote:
I'm developing a service which is two sites: a Mobile Site and a PC-Based
Site. The whole goal is to have them operate very similarly but, of course,
there will be many differences:

1. Web.configs will be different to handle cookieless vs. cookied Sessions
2. Mobile site will have no Master Pages (unfortunately)
3. Design of pages will be VASTLY different

However, many elements will be exactly the same:
a. I'll use most of the same classes for data access and other business
objects
b. The database in the backend is the same database

Here's my question: What's the best strategy for building these sites to
share code that's the same? It seems that in order to have two different
Web.comfigs (which I think I *must* have to support the differences between
Mobile and PC stuff), I must basically have two different sites. If I have
two different sites, I must have two different "App_Code" directories. This
means, I think, that I cannot share the same class files between the two
sites and must make copies of them. This seems like a shame.

Is there a better way to do all this?

Thanks for your help.

Alex
Jun 4 '07 #3

P: n/a
Hi Alex,

Based on your description, you're building two websites, one for mobile
clients and one for normal pc clients and they have same functionality and
backend data store, so you're wondering how to share the code logic as much
as possible between them, correct?

For this scenario, I think the most different of the two websites here are
of the ASP.NET front-UI interfaces, Mobile application's front UI layout
and display differ much from normal web application. I think what you can
share most between them should be the middle tier business or data access
components. Such as validation rules or data access utilities.

As you've mentioned that you will need to create separate copy of classes
put in each application's App_Code folder. Then, I suggest you consider
move much classes(that is common to both applications) into a shared class
library project. And both of the two web application can reference to the
same class library project to use those common component classes. How do
you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 4 '07 #4

P: n/a
Steven -

Yes, I agree. The thing is, I really have come to love the whole idea of the
App_Code directory because it allows me to publish the site just by copying
all of the source files without having to compile and build and all that. I
guess there's no way to do that when you are creating a separate class
library, right?

Alex
"Steven Cheng[MSFT]" wrote:
Hi Alex,

Based on your description, you're building two websites, one for mobile
clients and one for normal pc clients and they have same functionality and
backend data store, so you're wondering how to share the code logic as much
as possible between them, correct?

For this scenario, I think the most different of the two websites here are
of the ASP.NET front-UI interfaces, Mobile application's front UI layout
and display differ much from normal web application. I think what you can
share most between them should be the middle tier business or data access
components. Such as validation rules or data access utilities.

As you've mentioned that you will need to create separate copy of classes
put in each application's App_Code folder. Then, I suggest you consider
move much classes(that is common to both applications) into a shared class
library project. And both of the two web application can reference to the
same class library project to use those common component classes. How do
you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 4 '07 #5

P: n/a
Thanks for your reply Alex,

Yes, I agree that a class library project can not offer such feature that
make the source code directly deploy in target directory(without
precompile). However, for optimized deployment scenario that need
precompilation, using separate class library to seprate shared code logic
would be good idea.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.