Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi, I wanted to encode my url on page load. It has to work in a way that the page will always be encoded on page load. But it is not working, this page is a standalone page so there are no link to redirect user but I need to get it working for my project.

Please help thanks!

This is my Page_Load code
C#
protected void Page_Load(object sender, EventArgs e)
  {
      string destinationURL = "http://localhost:2094/PaymentSuccesful";

      string encodeURL = Server.UrlEncode(destinationURL);

      Response.Redirect(encodeURL);
  }
Posted
Updated 15-Jan-15 23:14pm
v2
Comments
Zoltán Zörgő 17-Jan-15 6:52am    
Any progress?

1 solution

The url you have does not need encoding. Please note that URL encoding has nothing to do with encryption - it encodes special characters to pass http traffic correctly. I have a feeling, that you want something else. A page itself can't be encoded. Redirection happens on client side based on a http header field, which can't be encrypted.

So what you want either can't be achieved, or you have to reformulate your question - please emphasize the use of encryption in your case keeping in mind that encryption and encoding are two different things.
 
Share this answer
 
Comments
Member 11237565 17-Jan-15 8:12am    
Did encryption on the query string, unable to do it on the link itself: PaymentSuccesful.aspx though. It would prompt IIS error.
Zoltán Zörgő 17-Jan-15 13:48pm    
You can't encrypt url. Well you can, but it is useless.
Sergey Alexandrovich Kryukov 30-Apr-15 2:34am    
Encryption?! Just use some logic.
—SA
Sergey Alexandrovich Kryukov 30-Apr-15 2:34am    
5ed.
—SA

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