Solved

ASP.NET/VB Redirect URI cannot contain newline characters

Posted on 2006-06-19
4
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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