在地址栏中隐藏查询字符串或使查询字符串不可编辑 [英] Hide a querystring or make querystring non editable in adress bar

查看:87
本文介绍了在地址栏中隐藏查询字符串或使查询字符串不可编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使查询字符串不可编辑或隐藏它,但在下一页传递其值?
我用过
< td onclick ="javascript:DoNav(''<%#Eval(" storeid)%>'');返回false;" >

我的JavaScript在这里

 function DoNav(id)
{
       document.location.href = "View.aspx?id="+id;
}

获取Bugid

在view.aspx.cs页面中获取我使用的ID.
Convert.ToInt32(Request.QueryString["id"])
我的问题是Querystring在地址栏中可编辑..在浏览器中

http://../../View.aspx?id = 1



如何删除它..
我用过

  var  testURL = "  + id;
 var  newURL = testURL.match( RegExp("  [^?] +"))
document.location.href = newURL; 


删除querystring ..但这样做时,我无法在view.aspx.cs页面中获取我的querystring值..

请帮我解决这个问题
在此先感谢

解决方案

我在这里看到7个答案.我仍然提出完全不同的建议,并认为是处理它的最佳方法之一.
尝试 URL重写.

在此处阅读:使用ASP.NET进行URL重写 [ MSDN:URL重写 [ URL路由 [将为该主题提供补充和帮助的讨论 [ ^ ]

AFAIK,这是使用查询字符串的缺点之一.您不能隐藏任何值(也不能将地址栏设为只读).最好的办法是尝试对查询字符串参数进行加密.


如果您不希望显示数据,请不要使用querystring.而是使用会话变量. [
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

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

解决方案

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[^]


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.


If you dont want the data shown, do not use querystring. Instead, use Session variables.[^]


这篇关于在地址栏中隐藏查询字符串或使查询字符串不可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆