Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how to make querystring non -editable or hide it but pass its value in next page?
i used
<td onclick="javascript:DoNav('<%#Eval("storeid")%>');return false;" >

my javascript goes here
 function DoNav(id)
{
       document.location.href = "View.aspx?id="+id;
}
to get bugid

In view.aspx.cs page to get id I used..
Convert.ToInt32(Request.QueryString["id"])
My problem is Querystring is editable in adress bar..in browser
as
http://../../View.aspx?id=1



How to remove it..
I used
C#
var testURL = "View.aspx?id="+id;
var newURL = testURL.match(new RegExp("[^?]+"))
document.location.href = newURL;

to remove querystring.. but on doing this i cannot get my querystring value in view.aspx.cs page..

Please help me to solve this problem
thanks in advance
Posted
Updated 15-May-11 18:52pm
v2

I see 7 answers here. I still propose something totally different and believe one of the best way to handle it.
Try URL Rewriting.

Read here: URL Rewriting with ASP.NET[^]
MSDN: URL Rewriting[^]
OR
Read about, In ASP.NET 4.0: URL Routing[^]

A discussion that would add on and help on the topic[^]
 
Share this answer
 
Comments
Albin Abel 17-May-11 6:28am    
My 5,
Sandeep Mewara 17-May-11 9:45am    
Thanks Albin.
AFAIK, this is one of the disadvantages of using query string. You cannot hide any values (nor make the address bar read only). The best you can do is to try and encrypt the query string parameters.
 
Share this answer
 
If you dont want the data shown, do not use querystring. Instead, use Session variables.[^]
 
Share this answer
 
You can encrypt your querystring ....

this http://devcity.net/articles/47/1/encrypt_querystring.aspx might help you.

Otherwise y dont u use sessions..

session["id"]=id.ToString();
 
Share this answer
 
v2
If QueryString is not mandatory, you can send values in headers which cannot be seen by anyone.
 
Share this answer
 
If Querystring is not mandatory, you can send values in headers which cannot be seen by anyone.
 
Share this answer
 
Querystrings are directly visible and can be easily editable.

If you are passing sensitive data then you can instead use session variable.

Session variables also comes with a cost of the performance as it is stored in inproc you should minimize the use of session variable as much as possible

You can also use headers so it can be send between the pages.

If you want to use the querystring only than encrypt it, but it will increase its size which are restricted in some old browser.

Another thing that you can do is URL Rewriting, which will give a custom URL which is also an SEO frienly one so you get the advantage of the Search Engine.

So the choice is yours..

Keep Googling...Enjoy Coding :)
 
Share this answer
 
Hi if you want to develop Secure Website then you can use <b>Hidden fields </b> or <b>Session Variable</b> .You can Pass the values in Hidden fields in pages instead of using those values in Query String and you can read those values in Next page.
 
Share this answer
 
v3
If you are worrying on SEO, try Sandeep Mewara's solution.

if you are worrying about protection try protective methods.

One is here
Preventive Method for URL Request Forgery- An Example with ASP.NET MVC[^]

Though it is in MVC you can use the logic in asp.

Apart from that you can pass parameters across pages using sessions, personalization and cross page posting. Choice is yours depends on the situation
 
Share this answer
 

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