views:

114

answers:

0

I'm trying to create some tests for aspx pages. I started with this link.

Now, there's a way to add a file (image in my case) to the postdata by overriding

public override string GetKnownRequestHeader(int index)

from SimpleWorkerRequest. However, in my HttpHandler (instead of aspx page), the file isn't in the Request.Files. Is there a way to add a File to the Request.Files? Request.Files is readonly.

Update:

The method

public override void SetEndOfSendNotification( EndOfSendNotification callback, object extraData )

is overriden. This is the code in it:

/// <summary>
/// Method that is called just before the ASP.Net page gets executed. Allows
/// setting of the Context object item collection with arbitrary data. Also saves
/// the Context object so it can be used later to retrieve any result data.
/// Inbound: Context.Items["Content"] (Parameter data)
///          OR: you can add Context items directly by name and pick them up by name
/// Outbound: Context.Items["ResultContent"]
/// </summary>
/// <param name="callback">callback delegate</param>
/// <param name="extraData">extraData for system purpose</param>
public override void SetEndOfSendNotification( EndOfSendNotification callback, object extraData ) 
{
    base.SetEndOfSendNotification( callback, extraData );

    this.CurrentContext = extraData as HttpContext;
    if (this.ParameterData != null) 
    {
        /// *** Use 'as' instead of cast to ensure additional calls don't throw exceptions

        if( this.CurrentContext != null )
            /// *** Add any extra data here to the 
            this.CurrentContext.Items.Add("Content",this.ParameterData);
    }

    // *** Copy inbound context data
    if (this.Context != null) 
    {
        foreach( object Item in this.Context.Keys) 
        {
            this.CurrentContext.Items.Add(Item,this.Context[Item]);
        }
    }
}

Now, I must admit, I do not know a lot of this SimpleWorkerRequest (yet), but is there a way to add in this method logic to add Files to the Request.Files?