473,412 Members | 3,015 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,412 software developers and data experts.

ASP .NET Application vs. Windows Service

I have an ASP .NET web application that displays information. At the
same time, i have a web service that collects information from various
client applications. This data needs to be processed continuously in
many ways and stored in the database. I need timers to poll the data
and process on it and write to the database. I need to have lots of
data cached as objects in memory as it is being used all the times. I
need to generate weekly reports from data in the database.

My question is this. Can I do this all in ASP .NET or do I need to have
a windows service? Can i keep my web application alive and all the
timers working? Has anyone done this before, actually used an ASP .NET
Application in this way?

Thanks

Mark

Nov 19 '05 #1
15 3466
"Untitled" <ma*******@hotmail.com> confessed in news:1107989521.867262.17080
@l41g2000cwc.googlegroups.com:
I have an ASP .NET web application that displays information. At the
same time, i have a web service that collects information from various
client applications. This data needs to be processed continuously in
many ways and stored in the database. I need timers to poll the data
and process on it and write to the database. I need to have lots of
data cached as objects in memory as it is being used all the times. I
need to generate weekly reports from data in the database.

My question is this. Can I do this all in ASP .NET or do I need to have
a windows service? Can i keep my web application alive and all the
timers working? Has anyone done this before, actually used an ASP .NET
Application in this way?

Thanks

Mark


You can do it either way.

But, if as you describe, your data source supports webservice protocols (ie,
SOAP), and there is to be no user interaction at the receiver, then you'd
probably want to implement as a webservice.

-- ipgrunt

Nov 19 '05 #2
For important timed background tasks as you describe, a Windows Service is
the best tool for the job. You might be able to coax ASP.NET into doing it,
but it would be a bit like trying to fit a square peg into a round hole.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Untitled" <ma*******@hotmail.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
I have an ASP .NET web application that displays information. At the
same time, i have a web service that collects information from various
client applications. This data needs to be processed continuously in
many ways and stored in the database. I need timers to poll the data
and process on it and write to the database. I need to have lots of
data cached as objects in memory as it is being used all the times. I
need to generate weekly reports from data in the database.

My question is this. Can I do this all in ASP .NET or do I need to have
a windows service? Can i keep my web application alive and all the
timers working? Has anyone done this before, actually used an ASP .NET
Application in this way?

Thanks

Mark

Nov 19 '05 #3

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:ex****************@TK2MSFTNGP09.phx.gbl...
For important timed background tasks as you describe, a Windows Service is
the best tool for the job. You might be able to coax ASP.NET into doing
it, but it would be a bit like trying to fit a square peg into a round
hole.


I wish there was an easy way to do this in IIS, since it forces you to
either run your code in two processes or use remoting.

If you web site is doesn't need the security and other services of IIS you
could host ASP.NET inside your service. Currently you must also supply an
HTTP server, but you can download Cassini for this. Just add a reference in
your service to Cassini.dll and start a server an unused port of your
choice.

http://www.asp.net/Projects/Cassini/...ndex=0&tabid=1

In .NET 2.0 you will be able to use the same HTTP server stack that IIS uses
in a process of your choice. So you will have all the performance and
security of IIS, without having to run your application under IIS.

http://msdn.microsoft.com/msdnmag/is...n/default.aspx

David
Nov 19 '05 #4
Thanks David, that was a very good post. Cassini seems like a good idea
untill .NET 2.0.

However, the ideal choice for development, performance and security
remains to do everything in the ASP .NET Web Application. I need to get
some information concerning that. I know it is possible because I have
tried it, but only for a short period of time. I simply need some sort
of documentation concerning this that would help me make a descision;
maybe an MSDN article that would compare Windows Services to Web
Applications. Or maybe an an article by someone who has done this
before.

Thanks guys

Nov 19 '05 #5

"Untitled" <ma*******@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Thanks David, that was a very good post. Cassini seems like a good idea
untill .NET 2.0.

However, the ideal choice for development, performance and security
remains to do everything in the ASP .NET Web Application. I need to get
some information concerning that. I know it is possible because I have
tried it, but only for a short period of time. I simply need some sort
of documentation concerning this that would help me make a descision;
maybe an MSDN article that would compare Windows Services to Web
Applications. Or maybe an an article by someone who has done this
before.


The problem is that the ASP.NET process model doesn't really support this.
Your application is not started automatically when IIS is started. It only
starts when the first HTTP request is made. So you must have a mechanism
to "tickle" your application every time IIS restarts. Furthermore you must
make sure that IIS never recycles your application, which it may do on
regular intervals or on reaching certian memory thresholds.

David
Nov 19 '05 #6
Another question comes to mind from the Cassini post by David. Even if
I did use Cassini. How would I host ASP .NET inside my Windows Service?
ASP .NET runs under its own service.

Mark

Nov 19 '05 #7
I am aware of these problems and I do have a "tickling" system that
should garantee both those things.

I'm looking for other potential problems, or live examples of this in
action. Our company cannot take such a blind risk. Strangely enough i
have found NO documentation or articles ANYWHERE concerning this.

ASP .NET does have timers. It is possible to start your own threads in
ASP .NET. Everything I want to do seems possible.

The only question is "Can I really do all these things in ASP .NET and
expect it to work just the same? Or is there something i'm unaware of?
Is there something else that is different between a Windows Service and
an ASP .NET Web Application that i do not know about"

Thanks Guys you have been really helpful

Mark

Nov 19 '05 #8
> The only question is "Can I really do all these things in ASP .NET and
expect it to work just the same? Or is there something i'm unaware of?
Is there something else that is different between a Windows Service and
an ASP .NET Web Application that i do not know about"
You can hammer a nail with a screwdriver, but it's a lot harder to do.
You're describing a Service, regardless of what tools you used to build it.
It should be built as a Service.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Untitled" <ma*******@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...I am aware of these problems and I do have a "tickling" system that
should garantee both those things.

I'm looking for other potential problems, or live examples of this in
action. Our company cannot take such a blind risk. Strangely enough i
have found NO documentation or articles ANYWHERE concerning this.

ASP .NET does have timers. It is possible to start your own threads in
ASP .NET. Everything I want to do seems possible.

The only question is "Can I really do all these things in ASP .NET and
expect it to work just the same? Or is there something i'm unaware of?
Is there something else that is different between a Windows Service and
an ASP .NET Web Application that i do not know about"

Thanks Guys you have been really helpful

Mark

Nov 19 '05 #9
Well its not just a Service. It's also a Web Service and a Web
application. I need to somehow have all three in one.

Either i'm able to make my Service a Web Service and a Web application,
maybe using Cassini as David described. Or i'm able to make my Web
application a Service as i'm suggesting.

Nov 19 '05 #10

"Untitled" <ma*******@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Another question comes to mind from the Cassini post by David. Even if
I did use Cassini. How would I host ASP .NET inside my Windows Service?
ASP .NET runs under its own service.


Cassini.dll allows you to host ASP.NET in your own service. You could not
run the Cassini web server on the same port as IIS, of course.

Here's a discussion of hosting Cassini.dll in a windows service:

http://www.asp.net/Forums/ShowPost.a...&PostID=560232

David
Nov 19 '05 #11
A Swiss army knife has quite a few tools in the same package. However, the
nail clippers are not good for carving.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Untitled" <ma*******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Well its not just a Service. It's also a Web Service and a Web
application. I need to somehow have all three in one.

Either i'm able to make my Service a Web Service and a Web application,
maybe using Cassini as David described. Or i'm able to make my Web
application a Service as i'm suggesting.

Nov 19 '05 #12
I read the posts. I understand how it is done. But I don't see anything
about NOT having the ASP .NET process run on its own. It still has to
be its own process running under its own memory space. This means I
cannot share objects with the Windows Service except through remoting.
This in turn means, when the ASP .NET recieves thousands of datasets
from my clien applications they have to be serialized again to be sent
to the Windows Service (because the windows service is the one doing
all the work). This also means whenever the user makes changes to data,
the changes have to go through remoting to my windows service and then
to the database. And finally, this also means that though I have lots
of data loaded in memory on my windows service, my ASP .NET Web
application still has to query the data from the database, or through
more remoting calls.

These are the things i'm trying to avoid.

Thanks again guys, I really apreciate it

Mark

Nov 19 '05 #13

"Untitled" <ma*******@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I read the posts. I understand how it is done. But I don't see anything
about NOT having the ASP .NET process run on its own.


If you write your own windows service and reference the cassini.dll, as
described in that post, ASP.NET will be running in your service process.
You will be able to share objects between ASP.NET and your service. The
only wrinkle is that ASP.NET will be hosted in a seperate AppDomain. You
can modify the cassini code to return your main service class a reference to
the created AppDomain and start the rest of your service code in that
AppDomain too. Then you won't have to marshal between the AppDomains.

Just add the following method to Cassini.Host.cs

public System.AppDomain GetDomain()
{
//Host is MarshalByRef and lives in the web app's AppDomain
//so this call is marshalled and run on a thread in the other AppDomain
return Thread.GetDomain();
}

And this to Cassini.Server.cs

public Host GetHost()
{
return _host;
}
Then you can get the AppDomain for your web application with

Server.GetHost().GetDomain()

And you can fire up your service types over there.

David

David
Nov 19 '05 #14
Apparently, even though I have access to the Domain i don't think i can
access its contents.

"Code running in one application cannot directly access code or
resources from another application. The common language runtime
enforces this isolation by preventing direct calls between objects in
different application domains. Objects that pass between domains are
either copied or accessed by proxy."

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconapplicationdomainsoverview.asp>

Nov 19 '05 #15

"Untitled" <ma*******@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Apparently, even though I have access to the Domain i don't think i can
access its contents.

"Code running in one application cannot directly access code or
resources from another application. The common language runtime
enforces this isolation by preventing direct calls between objects in
different application domains. Objects that pass between domains are
either copied or accessed by proxy."

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconapplicationdomainsoverview.asp>


Right, but with a reference to an AppDomain you can create an instance of
any MarshalByRef object in the AppDomain using
AppDomain.CreateInstanceAndUnwrap.

You would implement your main service class as a MarshalByRef object, put a
single .Run method on it, create it using AppDomain.CreateInstanceAndUnwrap,
and the hit Run. It will run in the target AppDomain.

http://msdn.microsoft.com/library/de...nwraptopic.asp

David
Nov 19 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael | last post by:
Hi, I have a windows service developed using c# and it needs to lunch another windows application. I have been trying to use Process class to do it but the problem is becase windows service...
0
by: CodeMonkey | last post by:
Hi, I was wondering if anybody could give me some advice on how to structure an application that I am about to start work on. The vague requirements will be: 1) Always-On monitoring of data...
2
by: Randall Powell | last post by:
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging...
13
by: Amjad | last post by:
Hi, Is there an equivalent to the "Application.Doevents" method in modules or Windows services? I want to make a Windows service that calls a DLL. The DLL would have all my functions and it...
4
by: Vijay Kerji | last post by:
Dear Friends, please read the following scenario... - A website which invites different users to register/participate in an initiative - Intial time period will be given to the user to access...
6
by: kumar_anil_gaya_India | last post by:
Hi All, I am facing one problem. I have one DLL called LogManagement which has ability to write to ExceptionLog and EventLog File. Both are separate file locate in Logs Diectory. I have two ...
2
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
1
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
Hi, I have 2 applications running, one Windows application project and the other windows services project. I want to call my Windows application in my windows services. I want to run them as...
3
by: Sylvie | last post by:
My Windows Application has two forms, one form contains a grid (lets say Stock Listing), and the other is a form of one stock, contains some edit boxes for one stock's fields.. Is it possible to...
22
by: robertgregson | last post by:
Using C#, .NET3.5, Visual Studio 2008 and WCF on Windows VISTA SP1, I have written a service, service host (as a C# console application) and a client. The service uses...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.