473,385 Members | 1,712 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,385 software developers and data experts.

programmatically access a web app via a windows service

Hi,

I need a general direction. I don't even know where to start
researching how to do this.

I have an existing dot net web application (It's mine, I wrote it)
that has some text fields and a button. The code-behind click event
of the button sends an SNPP conversation to a pager server.

I also have an existing dot net windows service running on a dedicated
machine with special hardware that can listen for and receive the
pages via radio. The purpose of the service is to monitor various
paging applications. It does so by continuously looping through a set
of test pages and listens for them to return.

My client now wants me to "monitor" the web application. I need to
have the windows service execute the web application and send a page
as if a human had done so. I have no idea how to proceed.

Is there an obvious definitive way of doing this that I am
overlooking? Does anyone have any creative ideas? If Microsoft is
monitoring this, do you have any suggestions?

Thanks in advance,
Doug
Jul 21 '05 #1
8 5832
Hi Doug,

Thanks for your post. .NET Class Library provides several classes (say,
System.Net.HttpWebRequest) which can be used to access web pages. I believe
the following MSDN article and sample are helpful:

HttpWebRequest Class
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnethttpwebrequestclasstopic.asp

SAMPLE: Visual C# .NET Networking Classes HTTP Internet Client
http://support.microsoft.com/?id=303436

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Hi Tian Min Huang,

Thanks for the response. I have investigated HttpWebRequest and
HttpWebResponse but these won't let me put text in a textbox and push
a button. I can simulate that activity and send a post to the server
as if a button click caused a postback, but to do that in Dot Net, I'd
have to correctly populate that hidden field with the encoded state
data. I don't expect that to be very do-able.

I seem to be having the most luck with the interop
SHDocVw.InternetExplorer. I was hoping, however, that there would be
a way to do this in managed code.

Have I missed anything? Is this my only option?

Thanks,
Doug
ti******@online.microsoft.com (Tian Min Huang) wrote in message news:<eP**************@cpmsftngxa06.phx.gbl>...
Hi Doug,

Thanks for your post. .NET Class Library provides several classes (say,
System.Net.HttpWebRequest) which can be used to access web pages. I believe
the following MSDN article and sample are helpful:

HttpWebRequest Class
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnethttpwebrequestclasstopic.asp

SAMPLE: Visual C# .NET Networking Classes HTTP Internet Client
http://support.microsoft.com/?id=303436

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3
Hi Doug,

Thanks for your update. The following KB article describes using Web
Browser control in .NET, please check it on your side. After loading a web
page in the control, then you can send keyboard messages to simulate a user
input and operation.

Web Browser in C# and VB.NET
http://www.c-sharpcorner.com/Interne...serInCSMDB.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
Hi Tian Min Huang,

Thanks for the link. It was very informative. I have, however,
looked into this and, unless I'm missing something, it won't work in
this case.

Since this has got to work in a Windows Service it must be completely
free of any UI. In a proof-of-concept windows application, I was able
to use it as a control just fine, but when I tried to simply
instantiate it as an object it complained. It seems to really want to
write to something and I couldn't placate it.

I was able to instantiate an instance of the InternetExplorer class in
the same DLL and it seemed happy not having a UI available. I am
worried about using this object for two reasons.

First, this seems like a pretty bulky object to leave lying around or
to be constantly creating and destroying.

Second, this Windows Service must continue looping 24/7 for months at
a time. Is this object "leak proof"?

Thanks again,
Doug
ti******@online.microsoft.com (Tian Min Huang) wrote in message news:<46**************@cpmsftngxa06.phx.gbl>...
Hi Doug,

Thanks for your update. The following KB article describes using Web
Browser control in .NET, please check it on your side. After loading a web
page in the control, then you can send keyboard messages to simulate a user
input and operation.

Web Browser in C# and VB.NET
http://www.c-sharpcorner.com/Interne...serInCSMDB.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5
Hi Doug,

Thanks for your response. I'd like to share the following information with
you:

1. Generally speaking, a Windows Service is desinged to be running
background without UI. Still, we are able to create a visible/hidden form
within Service as long as running the windows service in Local System
account, allowing service to interact with desktop.

2. I am glad to hear that you were able to automate Internet Explorer (by
instantiating an instance of the IE class). That is, you start Internet
Explorer from within your service. I believe this is a good method and
there is no need to worry about the issues like "IE is leak proof".

I look forward to your feedback.

Have a great day!
Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #6
Hi Tian Min Huang,

Sorry for the delay. I seem to have had a setback. the solution
using the InternetExplorer object works perfectly in a Windows
application and a console application (which is where I developed it),
but when I put it in my Windows service, it stops functioning.

I can call the "navigate" method without incurring an error, but the
object never fires any of its events unlike in the other environments.

I still can't help feeling that the problem is that the IE object
contains forms (visible or not) which are forbidden in a Windows
service.

Any more thoughts?

Thanks,
Doug

ti******@online.microsoft.com (Tian Min Huang) wrote in message news:<8N**************@cpmsftngxa06.phx.gbl>...
Hi Doug,

Thanks for your response. I'd like to share the following information with
you:

1. Generally speaking, a Windows Service is desinged to be running
background without UI. Still, we are able to create a visible/hidden form
within Service as long as running the windows service in Local System
account, allowing service to interact with desktop.

2. I am glad to hear that you were able to automate Internet Explorer (by
instantiating an instance of the IE class). That is, you start Internet
Explorer from within your service. I believe this is a good method and
there is no need to worry about the issues like "IE is leak proof".

I look forward to your feedback.

Have a great day!
Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #7
Hi Doug,

Thanks for your resposne.

As you know, the desktops of the interactive window station, Winsta0, can
be made to display a user interface and receive user input, but only one of
these desktops at a time is active. As you know, a service will be created
in the non-interactive window station by default, I believe that's the
cause of this problem. I recommend you configure your service as
interactive service by running the windows service in Local System account
and allowing service to interact with desktop, and then check whether or
not the problem still exists. Please refer to the following MSDN article
for detailed information:

Interactive Services
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/interactive_services.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #8
ti******@online.microsoft.com (Tian Min Huang) wrote in message news:<8N**************@cpmsftngxa06.phx.gbl>...
Hi Doug,

Thanks for your response. I'd like to share the following information with
you:

1. Generally speaking, a Windows Service is desinged to be running
background without UI. Still, we are able to create a visible/hidden form
within Service as long as running the windows service in Local System
account, allowing service to interact with desktop.

2. I am glad to hear that you were able to automate Internet Explorer (by
instantiating an instance of the IE class). That is, you start Internet
Explorer from within your service. I believe this is a good method and
there is no need to worry about the issues like "IE is leak proof".

I look forward to your feedback.

Have a great day!
Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


IE webcontrol is VERY LEAKY. I have a VB test case use IE webcontorl
that continuously hit a few pages on a website. The system loose 128K of
RM every loop. A 1GB RAM system will run out memory completely in over night
test. Search Google and you will find other had asked MS for fix for this.
There is not response from MS about this at all.

--
Browse source code and document for .NET CLI, Mozilla, Apache, NetBSD at
http://www.slink-software.com?E=SLinkEvn_1004
Jul 21 '05 #9

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

Similar topics

2
by: Vince Keller | last post by:
I dont know if this is the correct newsgroup to post questions on Windows Service. I am trying to install and uninstall a Windows Service programmatically. As far as I know, there isnt a class...
9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
13
by: Alexandra | last post by:
Hi, I have a hidden system file that I need to read. I am logged in as an administrator. I can not change the file attributes using the windows explorer.
3
by: Codex Twin | last post by:
Hello apologies if this is the wrong newsgroup to be sending this to. Basically, I have an ASP.NET application that I am trying to force to use a proxy server settings. This can be done by...
8
by: doug.h.taylor.accipitersoftware.com | last post by:
Hi, I need a general direction. I don't even know where to start researching how to do this. I have an existing dot net web application (It's mine, I wrote it) that has some text fields and...
1
by: Lonewolf | last post by:
Hi, could someone please enlighten me on how I could turn on the above mentioned two windows services programmatically? Reason is i am writing a program which needs to turn on these two services...
7
by: sunil | last post by:
Hi all, I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based on the code...
2
by: kmsultan1 | last post by:
Hello all, I need help in trying to access a web page from a windows service. I've actually already built a windows application (vb.net) that does this using the AxSHDocVw.AxWebBrowser class....
2
by: MalikTahirMahmood | last post by:
Hi, i am developing a car rental application, in which i required to get data from "salik Web site" UAE Toll system, I created one Desktop application in which i placed on webbrowser control and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.