/// <summary>
        /// Loads an exising Session type.
        /// </summary>
        /// <param name="session"> Loads a session type in the ScriptingDataDesigner.</param>
        public void LoadSession(Session session)
        {
            ScriptingApplication sd = new ScriptingApplication();

            foreach (SessionRequest req in session.SessionRequests )
            {
                if ( req.RequestType == HttpRequestType.GET )
                {
                    GetWebRequest getRequest = new GetWebRequest((GetSessionRequest)req);
                    sd.AddWebRequest(getRequest);
                }
                else if ( req.RequestType == HttpRequestType.POST )
                {
                    PostWebRequest postRequest = new PostWebRequest((PostSessionRequest)req);
                    sd.AddWebRequest(postRequest);
                }
            }

            _scriptingData = sd;
        }
        /// <summary>
        /// Sends POST Requests.
        /// </summary>
        /// <param name="postUri"> Post uri.</param>
        /// <param name="values"> Values to post.</param>
        /// <param name="stateData"> ResponseBuffer from site.</param>
        /// <param name="cookies"> Cookies from site.</param>
        /// <param name="formTag"> The HtmlFormTag value.</param>
        private void GetPostRequest(string postUri,ArrayList values,ResponseBuffer stateData, CookieCollection cookies, HtmlFormTag formTag)
        {
            // disable
            DisableFormView();

            // add Messaging
            ShowPostRequestMessage(postUri);

            if ( values != null )
                ShowPostedData(values);

            try
            {
                InitializeHttpCommands();
                postForm.ProxySettings = this.ProxySettings;

                if ( formTag.Enctype.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "multipart/form-data" )
                {
                    HttpRequestResponseContext context = new HttpRequestResponseContext();
                    PostWebRequest postReq = new PostWebRequest();
                    postReq.Form.ReadHtmlFormTag(formTag);
                    Ecyware.GreenBlue.Engine.Scripting.Cookies c = new Cookies(cookies);
                    postReq.Cookies =  c.GetCookies();
                    postReq.RequestType = HttpRequestType.POST;
                    postReq.Url = postUri;
                    postReq.RequestHttpSettings = this.GetHttpPropertiesFromPanel();
                    context.Request = postReq;

                    postForm.StartAsyncHttpPostFileUpload(context);
                }
                else
                {
                    postForm.StartAsyncHttpPost(postUri,this.GetHttpPropertiesFromPanel(),values,cookies);
                }
            }
            catch ( Exception ex )
            {
                this.txtMessaging.SelectionColor = Color.Red;
                this.txtMessaging.SelectedText = "Html Browser Error: " + ex.Message + "\r\n";

                textViewerForm.EditorText = ex.Message;
                // enable
                EnableFormView();
                this.navForm.StopNavigation();
                this.StopProgressBarEvent(this,new ProgressBarControlEventArgs("Ready"));
            }
        }
        /// <summary>
        /// Creates a new web request.
        /// </summary>
        /// <param name="httpRequestType"> The HTTP request type.</param>
        /// <param name="url"> The url.</param>
        /// <returns> A new web request.</returns>
        public static WebRequest Create(HttpRequestType httpRequestType, string url)
        {
            WebRequest request = null;

            switch ( httpRequestType )
            {
                case HttpRequestType.GET:
                    request = new GetWebRequest();
                    request.Url = url;
                    break;
                case HttpRequestType.POST:
                    request = new PostWebRequest();
                    request.Url = url;
                    break;
                case HttpRequestType.PUT:
                    request = new PutWebRequest();
                    request.Url = url;
                    break;
                case HttpRequestType.DELETE:
                    request = new DeleteWebRequest();
                    request.Url = url;
                    break;
                case HttpRequestType.SOAPHTTP:
                    request = new SoapHttpWebRequest();
                    request.Url = url;
                    break;
            }

            return request;
        }
        /// <summary>
        /// Executes a POST request.
        /// </summary>
        /// <param name="request"> Post request to execute.</param>
        /// <param name="index"> The request index.</param>
        private void ExecutePostRequest(PostWebRequest request, int index)
        {
            try
            {
                ConfigureOutputTransforms(request);

                _client.ProxySettings = this.Proxy;

                if ( request.Form.Enctype == null )
                {
                    _client.ExecutePostWebRequest(new HttpRequestResponseContext(request, index, false));
                }
                else
                {
                    if ( request.Form.Enctype.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "multipart/form-data" )
                    {
                        _client.ExecutePostWebRequestFileUpload(new HttpRequestResponseContext(request, index, false));
                    }
                    else
                    {
                        _client.ExecutePostWebRequest(new HttpRequestResponseContext(request, index, false));
                    }
                }
            }
            catch ( Exception ex )
            {
                AbortSessionRun(ex.ToString());
            }
        }