Announcement

Collapse
No announcement yet.

IIS and COM

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • IIS and COM

    I am working as a team member on a project and need to devise a quick way for the web developer to access data elements from the project.

    My question is this; Is there a way that COM objects can be used via a web app built for IIS? I know CGIs can be made and I'd like to avoid this. I am looking for a more direct solution or an out of the box solution from MS. Does AJAX, or ASP (or something else) have the ability to work with COM objects directly?
    Scott Slater
    Summit Computer Networks, Inc.
    www.summitcn.com

  • #2
    Yes, ASP does COM (ADO for data access) "out of the box" (given that ADO is installed on the IIS machine).

    Simple example:
    Code:
    Dim cn, rs, sConnection, sSQL
    
    sConnection = "Provider=SQLOLEDB;Data Source=<SQL server>;database=MyDatase;uid=MyUser;pwd=MyPwd;" 'MS SQL Server
    
    Set cn = Server.CreateObject("ADODB.Connection")
    Call cn.Open(sConnection)
    
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    sSQL = "SELECT ID, Lastname FROM tMyTable WHERE ID > 5 ORDER BY Lastname;"
    
    Call rs.Open(sSQL, cn)
    
    Do While Not rs.EOF
       Response.Write rs.Fields("ID").Value & ", " & rs.Fields("Lastname").Value & "<br />"
       rs.MoveNext
    Loop
    
    Call rs.Close
    Set rs = Nothing
    
    Call cn.Close
    Set cn = Nothing
    As you can see form the example, as long as the COM component is properly installed & registered, in ASP you create an instance of it with the Set <var> = Server.CreateObject("<COM Component>") syntax.

    Comment


    • #3
      I use PB CGI's to call COM objects on IIS.
      I use it to specifically convert HTML files to PDF's.
      It works great.

      Comment


      • #4
        Thanks for your replies. I'll have the web dev look into ASP.

        Thanks again!
        Scott Slater
        Summit Computer Networks, Inc.
        www.summitcn.com

        Comment


        • #5
          Unless you are IIS7 and .net, it's doable for interop but dumb down IIS7 to support asp it will save you a lot of heartache..
          Sr. Software Development Engineer and Sr. Information Security Analyst,
          CEH, Digital Forensic Examiner

          Comment


          • #6
            Thanks Thomas,

            I will have our web dev get back to me on what version she is using.

            I am trying to use a standard COM dll built with PB (non-ADO). Am I barking up the wrong tree or is this doable?

            I have a simple data wrapper COM object which connects to a custom server and sends data received via properties/methods to the server.

            I know that I could go to CGI as suggested, but am trying to do it directly via ASP.NET for now. I can successfully work with the objects using C#, and they are all visible to Visual Studio.

            Thanks again...
            Scott Slater
            Summit Computer Networks, Inc.
            www.summitcn.com

            Comment


            • #7
              I believe everything in IIS is first mapped via Handlers. IIS maps path specifications to a handler module. So you could map *.asp or /myweb to a handler and IIS would invoke on a first match found basis.

              There are CGI, webDAV, Isapi Handlers, and a few others, but I'm not aware of a COM handler. No reason you couldn't write one though.
              LarryC
              Website
              Sometimes life's a dream, sometimes it's a scream

              Comment


              • #8
                Originally posted by Scott Slater View Post
                I know that I could go to CGI as suggested, but am trying to do it directly via ASP.NET for now. I can successfully work with the objects using C#, and they are all visible to Visual Studio.
                Well, that should do the trick then.

                You just need to be aware that ASP.NET web applications run under the IIS user account (IUSR_xxx) and therefore have very restricted rights. While a plain C# application using your component may run error free, a similar web application might not until you set proper permissions.

                Comment


                • #9
                  Originally posted by Knuth Konrad View Post
                  Well, that should do the trick then.

                  You just need to be aware that ASP.NET web applications run under the IIS user account (IUSR_xxx) and therefore have very restricted rights.
                  Great! I'll pass that along to our ASP person. I am really hoping to avoid the CGI route since that would fall on my plate, and I am backed up with quite a few other projects at the moment.
                  Scott Slater
                  Summit Computer Networks, Inc.
                  www.summitcn.com

                  Comment

                  Working...
                  X