Programmatically access a web page via a windows service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kmsultan1
    New Member
    • Jan 2007
    • 4

    Programmatically access a web page via a windows service

    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.AxWeb Browser class. The code works perfectly in the windows application, but when I use the code in a windows service, the code doesn't work!

    I'm assuming this is because somehow the AxWebBrowser needs a desktop context to interact with (e.g. AxWebBrowser.Na vigate). I tried to use the option to "Allow service to interact with desktop", but that didn't seem to do anything!

    What I ultimately want to do (as per the code below), is to be able to print an HTML document (that references data from an XML doc) on the server. This has to be done from a windows service, as users would never log on to the server to run the application.

    Do you guys know how I can do this? I've been going crazy trying to find out the best way to do this, and would love to hear input from others.

    Thanks again
    kmsultan

    AxWebBrowser.Na vigate(strContr actURL, Nothing, Nothing, Nothing, Nothing)
    While Not (AxWebBrowser.R eadyState = SHDocVw.tagREAD YSTATE.READYSTA TE_COMPLETE)
    System.Windows. Forms.Applicati on.DoEvents()
    End While
    AxWebBrowser.Ex ecWB(SHDocVw.OL ECMDID.OLECMDID _PRINT, SHDocVw.OLECMDE XECOPT.OLECMDEX ECOPT_DONTPROMP TUSER, Nothing, Nothing)
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Here is an article that may help:
    HTML viewing and editing component for WinForms apps

    Comment

    • kmsultan1
      New Member
      • Jan 2007
      • 4

      #3
      I was able to create a windows .NET service that calls the windows application which has the web browser. When I made the service interact with the desktop (in the properties of the service), everything worked perfectly.

      I had to remove all Msgbox windows from my appliation, since the application is running in the .NET service context, and does not display windows/forms/etc on the screen.

      The application get called, and executes even when no user is logged on.

      Just thought I should share in case anyone else is having this problem.

      Thanks

      Comment

      Working...