Click here to Skip to main content
14,872,753 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is like this.

<asp:hyperlinkfield datatextfield="id" datanavigateurlfields="id" datanavigateurlformatstring="~/breport.aspx?id={0}"
="" headertext="ID">

when I click on hyperlink, the page is redirected and displayed contents correctly.
But in the address bar the URL is "websitename/breport.aspx?id=590" displayed.
I want to rewrite the URL "websitename/breport.aspx?id=590" as "website/seethereport" . What is the code in global.asax in asp.net 4.0 c#. Please give suggestions.

thank you in advance

What I have tried:

I tried for encoding the text using Server.UrlEncode(Eval("ID").ToString())
but ID text is not encoded and url "websitename/breport.aspx?id=590" appears as it is without encoding the text.
Posted
Comments
F-ES Sitecore 10-Apr-20 11:12am
   
If you remove the id then how does the page know what report to show? If you don't want the ID on the url then you'll need to do a form POST rather than a link. If you use a linkbutton instead and set the postbackurl field you can have it submit a post to your page instead so the id won't be on the url.

Note that that won't stop people looking at other IDs though, it will just make it slightly harder for them to do.
Member 14798070 10-Apr-20 13:20pm
   
ID is dynamic one. Which means that click on one row id is one number such as 570. When click on another row of gridview ID takes another number such as 670. Based on this ID numbers new page will be navigated. The navigated page contains URL as websitename/filename.aspx?fieldname=id. My intention is rewrite this URL as websitename/someothertext using global.asax file in asp.net c#. Please suggest.
F-ES Sitecore 11-Apr-20 10:34am
   
I don't think it is possible, to do what you need means turning a GET into a POST which url rewriting can't do.

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