Search the Blog Minimize
spacer
DNNDev Blogs: Most recent blog entries Minimize

What is Being POST-ed to My Page?

Dec 10

Written by:
12/10/2008 9:51 AM  RssIcon

Are you sending values to a page or receiving values from a page via HTTP POST? When doing so, it's often necessary to verify the values are being sent correctly and that the field names being used are the ones you expect. If you're an XMod user, this is useful if you're using the tag or tag or if you're receiving values into your form via the tag. Of course, POSTing values isn't an XMod-only activity and you may find use for this script elsewhere in your development activities.

Here is a copy-and-paste snippet of code you can put on your server to determine what is being passed to a page via HTTP POST. Simply copy the code and put it into an ASPX page on your server. Then, set your XMod <redirect> target to that page. It will display the POSTed values at the top of the page, followed by a list of everything sent to the page, which can also be useful when debugging things.  This works with any call to the page, so it isn't just for XMod.

Here's the code:

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Net" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Display of All Values Passed/Posted</title>
<script runat="server">
Protected Sub Page_Load(ByVal sender as System.Object, ByVal e as System.EventArgs)
    For i as integer = 0 to Request.Params.AllKeys.Length - 1
        Dim strKey as string = Request.Params.AllKeys(i)
        lblOutput.Text &= "<strong>" & strKey & "</strong> " & Request.Params(strKey) & "<br />"
    Next
    For i as integer = 0 to Request.Form.AllKeys.Length - 1
        Dim strKey as string = Request.Params.AllKeys(i)
        lblPostedValues.Text &= "<strong>" & strKey & "</strong> " & Request.Form(strKey) & "<br />"
    Next

End Sub
</script>
</head>
<body>
<h1>POST'ed Values</h1>
<asp:label id="lblPostedValues" runat="server" />
<h1>Display of All Values Passed/Posted</h1>
<asp:label id="lblOutput" runat="server"/>
</body>
</html>

Tags:
Categories:
Location: Blogs Parent Separator DNNDev_Blog

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
spacer
dummy