Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I am working asp.net c# web application.I want to create a application in which i have to send automatically mail in every 1 hour to user.
I used web service for that...I uploaded my application on web server,and when run the page one time web service start and in every one hour mail is sent.

But my problem is that, this web service is stopped after four hours.And again for start web service we have to run the page.And it again stop after 4 hours.

I need that web service will never stop,and my mailing functionality is working all the time.

Please help...Its urgent...

Thanks
Posted
Comments
walterhevedeich 14-Apr-11 1:21am    
Check the event viewer to see the detailed error. There must be a reason why it is stopping.
Pong D. Panda 14-Apr-11 1:21am    
Can you explain how you call your mail service? I think it is a garbage collection issue of bad programming practice.

1 solution

This isn't something that should be done with a web app. Web applications are called from a page request, and are expected to go away reasonably quickly – and while ASP.net keeps the idea of an 'application instance' around for an entire browsing session, it's not designed to persist after the user has gone away. Instead, write a daemon (for a Windows server, a service) to send the mails, or schedule a repeating job.

We actually did something quite similar in a recent project and what we did was create a Windows service that checked a database table for who to send mail to (every 10 minutes or so if I remember right). The web app (back end to a Silverlight app, mostly) posted records to that table when it found that a user needed an email.

A web service is generally if you want to call the service from elsewhere, I don't see the reason to use one when it is just to be called locally. But you should be able to host a web service indefinitely. Check the event logs as the comments mention, you are probably doing something wrong and that should give you a clue.
 
Share this answer
 
v2
Comments
Perry Bruins 14-Apr-11 10:08am    
In IIS, there is something like app pool recycling. It looks like your webservice application is being recycled after 4 hrs.

Anyway, I agree with the above comments; this is not something you want to do from a webservice.

Regds, Perry
Sergey Alexandrovich Kryukov 14-Apr-11 12:40pm    
I agree. More fundamentally, the problem is quite solvable but is not limited to client-server. Rather, this is publisher subscriber, and a very simple kind. Subscription along can work via Web application though.

My 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900