Request.Form between HTTP and HTTPS pages in ASP.NET

627 views Asked by At

I have a strange situation and google isn't helping me out. I have an admin site which is in simple HTTP who posts data to a different site running under HTTPS. The HTTP admin site (which I don't have direct access to) is sending the info via basic POST, and I'm trying to capture the Request.Form values in the HTTPS site. It works perfectly well in dev, due to the fact that the receiving site isn't running under SSL, but in prod, I have the Request.Form as empty. Someone could enlighten me? The basic HTTPS request code is below:

Dim nvm As NameValueCollection = Request.Form
Dim _idInscricao As String
Dim _Origem As String

litMensagem.Text = "Wait..."

    If nvm.Keys.Count = 0 Then
        litMensagem.Text = "Error recovering data. No keys found."
        Exit Sub
    End If

    For Each _Key As String In nvm.Keys
        If _Key.ToLower.EndsWith("idinscricao") Then
            _idInscricao = nvm(_Key)
        End If
        If _Key.ToLower.EndsWith("origem") Then
            _Origem = nvm(_Key)
        End If
    Next

    If _idInscricao Is Nothing OrElse String.IsNullOrEmpty(_idInscricao) _
        OrElse _Origem Is Nothing OrElse String.IsNullOrEmpty(_Origem) Then
        litMensagem.Text = "Error recovering data."
        Exit Sub
    End If
1

There are 1 answers

0
Jason On

I found this question because I was having the same problem, and I need to thank dana for the fiddler recommendation.

Using Fiddler, I found out what was going on. My page was on HTTPS, and the form that I was posting posted to HTTP. I couldn't figure out why my form structure on the posted page was empty.

Turns out the server couldn't find the http version of the file and did an automatic redirect to the https version, doing a GET with my form variables. They aren't available in the form scope with a GET. (FWIW, I'm using CFML.)

Once I changed the form action to post to HTTPS, everything worked like a charm.

-jason