views:

529

answers:

4

I have a DTS job that is using the MSXML2.XMLHTTP3.0 object to generate a post request to an ASP.NET application. Under the covers, the ASP.NET application is using System.Reflection to acquire some assembly information and I receive the following exception:

System.Web.HttpException Error Code: -2147467259 Message Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.

DTS Job Code:

Dim objSvHTTP
Dim PostData

Set objSvHTTP = CreateObject("Msxml2.XMLHTTP.3.0")
objSvHTTP.open "POST", "http://www.mywebsite.com", false
objSvHTTP.send

If (objSvrHTTP.responseText = "") Then
    //do something
Else
    //do somethiing else
End If

ASP.NET Application Code:

string WebPath = "D:\mywebsite\bin\mywebsite.dll";
Assembly UI = Assembly.LoadFrom( @WebPath );
Type t = UI.GetType( "MyWebsite.BasePage" );
MethodInfo MyMethod = t.GetMethod( "MyMethod" );
object obj = Activator.CreateInstance(t); 
MyMethod.Invoke( obj, null);

Question is, do I need to provide vaild Active Directory credentials in the XMLHTTP request to the ASP.NET application to avoid the error message

A: 

Judging by the exception message this does not look like an authentication problem to me. Could it be that the invoked method tries to access the ASP.NET Session? That would explain the exception.

csgero
+1  A: 

Try this: http://support.instantasp.co.uk/Topic4710-31-1.aspx

Israr Khan
A: 

@Israr Khan:

We eventually found a workaround by not executing the reflection code when the DTS called the particular web page that was required for the process.

This would explain why we were getting mixed results when we were trying to resolve this issue in our development and production environments. I did a comparison of the web.config files in each environment and noticed that the Session reference in the HttpModules section was in our production environment, but not in our development environment.

The process worked in development and did not work in production. I have submitted this suggestion to my co-workers to see if they want to try this solution instead of the workaround.

Michael Kniskern
Roger - hope it works ;)
Israr Khan
A: 

@Israr Khan:

I spoke with my co-workers and they had already tried to the suggested solution by adding the Session variable to the HttpModule section of the web.conifg. They were still getting the same error stated in the original question.

They are going to remove the property in production just to keep the web.configs file in sync.

Michael Kniskern