在asp.net中删除查询字符串的URL [英] Removing a querystring from url in asp.net

查看:227
本文介绍了在asp.net中删除查询字符串的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要当用户点击一个特定的LinkBut​​ton删除查询字符串。 因此,例如,如果查询字符串是 http://UserProfileManager.com?UserID=1234 ....当用户点击LinkBut​​ton的,我想要的网址是 http://UserProfileManager.com 。问题是,一切都在一个页面上,而我使用的ASP:面板来显示和隐藏网页的不同区域

I need to remove a querystring when a user clicks a particular LinkButton. So for example if the querystring is http://UserProfileManager.com?UserID=1234 .... when the user clicks on the Linkbutton, I want the url to be http://UserProfileManager.com. The issue is that everything is on one page, and I am using asp:panel to show and hide different areas of the webpage.

任何想法,将AP preciated。

Any ideas would be appreciated.

推荐答案

您有几种选择:

1)在你的code后面,只需设置的LinkBut​​ton的URL到更短的地址,如果查询字符串中包含一个用户名键:

1) In your code behind, just set the LinkButton's URL to the shorter address if the querystring contains a "UserID" key:

if (Request.QueryString["UserID"] != null) {
    this.LinkButton.PostBackUrl = "http://UserProfileManager.com";
} else {
    // other address
}

2)发送在一个隐藏字段,而不是查询字符串的用户名。

2) Send the UserID in a hidden field instead of the querystring.

3)分离视图和编辑页面 - 把一切都在一个*的.aspx很可能会造成更多的麻烦比它的价值在路上

3) Separate your view and edit pages - putting everything in one *.aspx is probably going to cause more trouble than it's worth down the road.

这篇关于在asp.net中删除查询字符串的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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