Home All Groups Group Topic Archive Search About

RE: HttpContext.Current always returns NULL when called from Classic ASP

Author
1 Mar 2007 3:51 PM
Les Bell
I am trying to use the ciode suggested. I have the following code (that works as a class in asp.net) but compiled into a dll and used in a classic asp page I get an error "System.__ComObject"

Here is the code:

if(System.Web.HttpContext.Current != null)
                {
                    strRemoteAddr = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                }
                else
                {
                    try
                    {

                        ASPTypeLibrary.Request oRequest = (ASPTypeLibrary.Request)
                            System.EnterpriseServices.ContextUtil.GetNamedProperty("Request");
                        strRemoteAddr = oRequest.ServerVariables["REMOTE_ADDR"].ToString();
                    }
                    catch(Exception e)
                    {
                        m_lastfailurereason = "Sorry, method for obtaining remote address failed" + m_remoteAddr + "Exception: " + e.ToString();
                        return false;
                    }
                }   

Can you suggest how it could be made to work?

From http://www.developmentnow.com/g/6_2003_10_0_0_68266/HttpContext-Current-always-returns-NULL-when-called-from-Classic-ASP.htm Posted via DevelopmentNow.com Groups http://www.developmentnow.com

AddThis Social Bookmark Button