c# - 从 asp.net 中的 url 中删除查询字符串

标签 c# asp.net .net-3.5 url panel

您好,当用户单击特定的 LinkBut​​ton 时,我需要删除查询字符串。 例如,如果查询字符串是 http://UserProfileManager.com?UserID=1234 ....当用户单击链接按钮时,我希望 url 为 http://UserProfileManager.com 。问题是所有内容都在一页上,我使用 asp:panel 来显示和隐藏网页的不同区域。

任何想法将不胜感激。

最佳答案

您有多种选择:

1) 在后面的代码中,如果查询字符串包含“UserID”键,只需将 LinkBut​​ton 的 URL 设置为较短的地址即可:

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

2) 在隐藏字段中发送 UserID,而不是查询字符串。

3) 将 View 页面和编辑页面分开 - 将所有内容放在一个 *.aspx 中可能会带来更多麻烦,而不是带来任何好处。

关于c# - 从 asp.net 中的 url 中删除查询字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2957457/

相关文章:

asp.net - jQuery 发布到 asp.net 页面错误 : The length of the query string for this request exceeds the configured maxQueryStringLength value

c# - SignalR OnConnected - 向连接的客户端发送消息

.net - 有没有办法从 .NET 3.5 中提取 .NET 2.0?

.net - 单个 .NET 进程是否有内存限制

c# - Linq-To-Sql Dynamic-Where-Clauses 在 Framework 3.5 中甚至可能吗?

c# 如何在客户端管理 wcf 服务代理生命周期?

c# - 在最后一项和列表框末尾之间添加空格

javascript - unity 从一个脚本到另一个脚本的变量访问

javascript - 拖放到数据库 mvc 后保存图像顺序

c# - 没有注册类型 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' 的服务