Solved

ASP.NET/VB Redirect URI cannot contain newline characters

Posted on 2006-06-19
4
373 Views
Last Modified: 2008-01-09
hi,I am having a problem of redirecting when the user presses the Enter key as one of the things in the remarks textbox. When the user hits enter key I want to just ignore and submit whatever is keyed in. How do I do that?

Dim query As String = Request.Url.Query.Substring(0, Request.Url.Query.LastIndexOf("&"))

query += "&remarks=" & Trim(remarksTxt.Text)
query = "monthLyreport.aspx" & query
Response.redirect(query)


somebody recommended this b4 redirecting.....
query = HttpUtility.UrlEncode(query)

but this results in my URL being
monthLyreport.aspx%3fA%3dABC%26B%3dABC%26C%3d6%26D%3d06%26remarks%3dhaha

instead of
monthLyreport.aspx?A=ABC&B=ABC&C=6&D=06&remarks=haha

i.e
? is replaced by %3f
& is replaced by %26
= is replaced by %3d

Thanks in advance
0
Comment
Question by:obajaber
4 Comments
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16940537
hai,
Use Server.UrlEncode method

Dim query As String =Server.UrlEncode( Request.Url.Query.Substring(0, Request.Url.Query.LastIndexOf("&")) )

query += "&remarks=" & Server.UrlEncode(Trim(remarksTxt.Text) )
query = "monthLyreport.aspx" &Server.UrlEncode(query )
Response.redirect(query)

regards
pradeep
0
 

Author Comment

by:obajaber
ID: 17138708
Wait, I tried the above solution. It was of no help, It still couldn't work. However, a friend recommended using he approach below: it worked.

'for the sending page
            Dim bQuery As Byte()
            Dim sQuery As String
            bQuery = Encoding.ASCII.GetBytes(Trim(remarksTxt.Text))
            sQuery = Convert.ToBase64String(bQuery)
            query += "&remarks=" & sQuery
            query = "monthlyReport.aspx" & query
            Replace(query, "", "%20")
            Response.Redirect(query)
'for the receivng page
  Dim bQuery As Byte()
        Dim sQuery As String = "None"
        If Request("Remarks") <> "" Then
            bQuery = Convert.FromBase64String(Request.QueryString("Remarks").ToString)
            sQuery = Encoding.ASCII.GetString(bQuery)
        End If
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17160209
PAQed with points refunded (30)

DarthMod
Community Support Moderator
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now