tags:

views:

188

answers:

1

My asp.net form handler only receives form method post data when IIS is configured for integrated windows authentication. When I switch it to anonymous authentication the request.form collection is empty. I would like IIS configured for anonymous authentication. What could be causing this? I have included my code below:

Here's my form page HTML (there's no code behind for it):


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Testing.aspx.vb" Inherits="Testing" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <title></title>
</head>
<body>
    <form name="frm" method="post" action="TestResults.aspx">
    <input type="text" name="mydata" value="" size="25" maxlength="255" />
    <input type="submit" name="submit" value="Submit" />
    </form>
</body>
</html>


Here's my form handler HTML code with the code behind to list all form variables:


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestResults.aspx.vb" Inherits="TestResults" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<body>
    <div id="resultsid" runat="server">
    </div>
</body>
</html>


Partial Class TestResults
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim aString As String = ""

    For Each item As String In Request.Form
      aString &= item & " = " & Request.Form(item) & "<br />"
    Next

    Me.resultsid.InnerHtml = "<b>The Data:</b><br />" & aString
  End Sub
End Class
A: 

Your form tag is missing the runat=server.

Edit: Looking a little closer at what you are attempting to do, you are trying to do a cross page postback. This type of postback is a bit more involved in asp.net, than it was in old asp. This article might be helpful:

http://www.c-sharpcorner.com/UploadFile/DipalChoksi/xpgpostbk%5Fasp2%5Fdc08102006235543PM/xpgpostbk%5Fasp2%5Fdc.aspx

Jim Petkus
I added the runat="server" to the form tag. That didn't fix the problem. Thanks for the suggestion though.
Actually, you should be able to leave the runat="server" off the form, ignore the whole postback mechanism, and just poke around in Request.Form directly. Not necessarily a great idea and certainly not very ".NET-y", but it *should* still work.
stevemegson
I'm inclined to just ditch my cross page postback strategy to see if I can get at the Request.Form contents.
Changed my code to just submit data to itself (no cross page postback). It works when IIS is set to integrated windows authentication. It doesn't work when IIS is set to anonymous authentication. When it works I'm able to get my data from the Request.Form("mydata") collection.
Reworked my code to try the cross page postback. It will only work when IIS is set to integrated authentication. It will not work when IIS is set to anonymous authentication. I don't think this is a code issue any longer. I think it's an IIS issue