Asp – Request.Form not working when IIS is set to anonymous authentication

asp.netiis

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">

<html xmlns="http://www.w3.org/1999/xhtml">
<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">

<html xmlns="http://www.w3.org/1999/xhtml">
<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

Best Answer

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_asp2_dc08102006235543PM/xpgpostbk_asp2_dc.aspx