Solved

ASP.NET/VB Redirect URI cannot contain newline characters

Posted on 2006-06-19
4
394 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

831 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