Looking for feedback on code handling COM/ASP and .NET/ASPx Request object 
Author Message
 Looking for feedback on code handling COM/ASP and .NET/ASPx Request object

Hello friends.

I'm new to the .Net world and I'm looking for feedback.

I posted a message a few days back asking for help but I
managed to struggle through and get something working. I'm
not too happy with the solution so I'm asking for some
feedback from you pros out there to help me learn and
improve the solution.

We are porting a pre-existing VB6 COM+ error handling
object to .NET. The object is a common error handler that
we use in all of our COM+ web and form based applications.
One of the things it does is try to get any interesting
HTTP Request data (if it is a web app) we need for logging
to a database (we also get ADO, VB ErrorObject, and user
defined data from the client).

We want to move the old error handler to .NET so we can
use it in a native .NET applications in addition to our
COM+ VB6 based applications. Initially, I was having
trouble getting it to work in COM interop because of the
differences in the ASP versus ASPX Request object types.

My solution (that I don't like) is to define two public
properties on the VB.NET object (as opposed to the
original version's single property); one property is
called ASPxRequestObject and it is typed as the new
System.Web.Request object, and the other property is
called ASPRequestObject that is typed as the old
ASPTypeLibrary.Request object through interop. I only
expose the old ASPTypeLibrary.Request interface to the
COM+ applications through explicit interface
implementation in the .NET object that implements this
solution, so the COM+ clients will only see that
interface. It works but I would like a single interface
solution.

The next problem I had was trying to use the old
ASPTypeLibrary.Request object -- it behaves differently in
VB.NET than in VB6 - the QueryString and ServerVariables
collections now return an IStringList so I can't read them
right into a String variable, but I found a solution I
think works, but I find it cumbersome and less than
elegant - there must be a better way and I am just too
rookie.

What I don't like about this solution so far:

1. Two interfaces is less than ideal - there must be
better (probably best solution) way to do this with one
public property interface that can handle both the new
ASPx System.Web.Request and the old ASPTypeLibrary.Request
objects to both COM+ and .NET in an easy way. Inheritance
or overloading? Is there some way to equate old type
libraries to the new ones, like load the
system.web.request library with the old
asptypelibrary.request object?

2. Am I missing something with the IStringList interface
to the old ASPTypeLibrary.Request interface? Is there a
better or preferred way to work with these objects?

I think there are other criticisms possible that I am
forgetting to write here.

I've included the code below that I use in the error
handler to get the Request data -- I don't like having to
know what the object type is. It assumes that a single
error event can only support errors from ASP or ASPx, but
not both, and the implementation to get the data out of
the different data types is unique to that data type.

Any feedback you can offer would be great!

Thanks.

-----------------------------------------------------------
--------------------------------------------------------
SAMPLE CODE:
------------

        If Not ASPxRequestObject Is Nothing Then
            'Set a Property of an URL and httpquerystring
for Logging Manager
            URL = ASPxRequestObject.ServerVariables.Item
("URL").ToString
            If Len(ASPxRequestObject.ServerVariables.Item
("QUERY_STRING").ToString) > 0 Then
                HttpQueryString =
ASPxRequestObject.ServerVariables.Item
("QUERY_STRING").ToString
                URL = URL & "?" & HttpQueryString
            End If
            'server veriable collection returns the
ALL_RAW with vbCrLf characters
            'that cause the stored proc to cut the value
of -- replace with ""
            All_Raw = Replace
(ASPxRequestObject.ServerVariables.Item
("ALL_RAW").ToString, vbCrLf, "")
            Remote_Addr =
ASPxRequestObject.ServerVariables.Item
("REMOTE_ADDR").ToString
        ElseIf Not ASPRequestObject Is Nothing Then
            'Set a Property of an URL and httpquerystring
for Logging Manager
            Dim objStringList As ASPTypeLibrary.IStringList
            Dim strURL As String
            Dim strQueryString As String
            'Get the base URL from server variable
collection
            objStringList =
ASPRequestObject.ServerVariables.Item("URL")
            strURL = CStr(objStringList(1))
            'Get the query string from server variable
collection
            objStringList =
ASPRequestObject.ServerVariables.Item("QUERY_STRING")
            strQueryString = CStr(objStringList(1))
            'Set URL property to ServerVariable URL -
append qurey string if it exists
            If Len(strQueryString) > 0 Then
                URL = strURL & "?" & strQueryString
                'Set HTTPQueryString property
                HttpQueryString = strQueryString
            Else
                URL = strURL
            End If
            'Get the RemoteAddr entity
            objStringList =
ASPRequestObject.ServerVariables.Item("REMOTE_ADDR")
            Remote_Addr = CStr(objStringList(1))
            'Get the ALL_RAW entity
            objStringList =
ASPRequestObject.ServerVariables.Item("ALL_RAW")
            'server veriable collection returns the
ALL_RAW with vbCrLf characters
            'that cause the stored proc to cut the value
of -- replace with ""
            All_Raw = Replace(CStr(objStringList(1)),
vbCrLf, "")

-----------------------------------------------------------
--------------------------------------------------------



Sun, 06 Feb 2005 08:45:44 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem passing VB COM+ ASP Request object to .NET component System.Web.HTTPRequest through COM interop

2. ASP Request Object into ASP.Net

3. Passing Form Fields to VB.NET Custom Business Object in an ASP.NET Code Behind Page

4. COM-Object in ASP with COM-Object as parameter

5. COM-Object in ASP with COM-Object as Parameter

6. com object will not read registry when com object called from asp (vb works fine)

7. British Pound sign disappears when POSTing from ASP to ASPX (VB.NET) page

8. What is the difference between .asp vs .aspx(.net)

9. ASP.NET - aspx

10. MAC address of ASP.NET Request or VB.NET connection

11. vb.net code transform to asp.net code?

12. Need to Access ASP Session Objects from External COM Object

 

 
Powered by phpBB® Forum Software