Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 11, 2012 02:02 PM by wavemaster
Oct 10, 2012 07:44 PM|LINK
Can I create a process in Webmatrix that would keep running for hours maybe even more than a day?
The process would be started by code and it would end by code as well.
When it is running, it would be making successive HTTP Get requests to a remote server.
Not looking for code (although that would be nice), more interested to see if a process can be alive this long?
Oct 10, 2012 07:45 PM|LINK
You'd be bettter off doing something like that as a windows service, and kicking it off from an event or schedule.
Oct 10, 2012 08:05 PM|LINK
Can you clarify what you mean?
It won't work?
Can I have a Windows service running inside of my website (WebMatrix).
I would be kicking it off from an event and it will follow a schedule. Maybe 15 queries in a matter of 3 days?
Oct 10, 2012 08:19 PM|LINK
The Windows service would be a separate application, but will run on the server - assuming you have permission to install Windows services on your web server. Maybe it would be better if you described the problem you are trying to resolve. There could be
other approaches that are more suitable for you.
Oct 10, 2012 08:59 PM|LINK
You asked for it, so here we go.
My application allows a user to send an SMS to another user, anonymously, by using the Twilio service.
User 1 enters subject and body, and hits send (on my website);
User 2 receives that same message which comes from one of my Twilio phone numbers;
User 2 sends a reply to my Twilio phone number;
The necessary information from the reply is stored in my Twilio log.
AFAIK, Twilio does not send notifications when new messages arrive. I am figuring I would need to request the log via a HTTP Get request.
What helps is that I know when I expect a reply, so I could start doing the requests then. And stop when the reply has been received.
The piece of code that is doing these request would have to be initiated from code (i.e. a reply message is expected), and would stop when a the reply has been received, without any user intervention or browser window being open.
There would be major complication when the message volume gets big, but for now I am willing to ignore the requirements for that until a later date. I just don't want to personally have to monitor the Twilio log.
I am using Azure web hosting, I have seem something there where I can add a virtual machine.
Oct 10, 2012 09:22 PM|LINK
Depending on your requirement and the frequency with which you need to poll the Twilio service, you have a few options. One is to create a Windows service as mentioned before that polls Twilio on a timer. Another is to use Windows Task Scheduler to do the
same thing. Both of those require a level of access to servers that most hosting companies don't provide, and neither option is relevant ot ASP.NET and therefore this forum. I know nothing about Azure so I couldn't advise whether either option is viable in
The ASP.NET solution would be to fire a request using the WebClient class every time a user visits your site. You can use the Session_start event in global.asax, which fires when a session - or series of connected page requests - begins. Or you can use the
Begin_Request event, which fires whenever a page is requested. An alternative to Begin_Request is to put a _PageStart file in your root folder and add the code there.
Oct 10, 2012 09:59 PM|LINK
I can put the Begin Request event trigger in a _PageStart file located in the Members folder, wouldn't that fire every time a page is requested from the Members folder?
Oct 11, 2012 04:41 AM|LINK
Code in a _PageStart file located in a particular folder will be executed every time a file is requested in that folder or any of its subfolders.
Begin_Request only belongs in a global.asax file.
Oct 11, 2012 02:02 PM|LINK
I just learned that Twilio does indeed push new messages to a server.
Makes life a lot easier!