Solved

ASP.NET/VB Redirect URI cannot contain newline characters

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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