473,323 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Sharing Objects Between ASP.NET "Sites"/Projects

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
5 1715
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: a | last post by:
I keep getting this message, "unable to get the project file from the web server" when I try to open a new project that I just copied. I created a virtual director with IIS 5 (VS2002). Trying to...
4
by: Anders K. Jacobsen [DK] | last post by:
Hi I have some common UserControls i want to share between to sites (on the same mashine but on diffrent virtual paths). right now i have on solution file with aprox 10 projects. 2 of these is...
54
by: m.roello | last post by:
In the book: "Working with Microsoft Visual Studio 2005" Craig Skibo wrote: "The power of Visual Studio 2005 lies in its ability to empower users to build, test, and debug powerful applications...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
15
by: Neo | last post by:
Hello All, I found that ASP.net website only accepts code withing site directory. This creates big hurdle in shairng code. How to share code between two websites, like the way share between two...
2
by: Lucky | last post by:
hi guys, few days back i've posted a question regarding how can i get the list of the websites form the IIS, at this location: ...
12
by: Tyno Gendo | last post by:
Hi everyone I wondered what if any methods people here use to speed up their PHP code (ie. speed at which you produce your code). Things like 'code templates', 'base objects' for this and...
19
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
3
by: Jethro | last post by:
Hi guys, I have inherited a .NET 2.0 web project. It consists of a root site, and 3 sub directories. Ideally these are seperate projects/websites. The root is a customer- facing one, and the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.