Click here to Skip to main content
14,880,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using asp.net/VB.net in my app.
I have a button which onclick I redirect to another page:

VB
Response.Redirect("/MyPage.aspx?userName=myUser")

and this page has a handler, so in ProcessRequest I use the following method to read userName:

VB
Public Sub ProcessRequest(context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim lUserName As String = Mid(context.Request.UrlReferrer.ToString, context.Request.UrlReferrer.ToString.LastIndexOf("userName=") + Len("userName=") + 1)
End Sub


But I had to use POST method instead of GET, so I changed the way of redirect to:
VB
Dim sb = New StringBuilder()
Dim sb = New StringBuilder()
sb.Append("<html>")
sb.AppendFormat("<body  önload='document.forms[""form""].submit()'>")
sb.AppendFormat("<form name='form' action='{0}' method='post'>", "/MyPage.aspx")
sb.AppendFormat("<input type='hidden' name='userName' value='{0}'>", "myUser")
sb.Append("</form>")
sb.Append("</body>")
sb.Append("</html>")
Response.Write(sb.ToString())
Response.End()
Response.Write(sb.ToString())
Response.End()


How to read the param (userName) now in handler class?? since I can't use the UrlReferrer anymore.
Posted

1 solution

Use context.Request.Form to access the form variable collection.

http://msdn.microsoft.com/en-us/library/system.web.httprequest.form(v=vs.110).aspx[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900