本文介绍了从编码链接ASP.NET获取参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从编码链接中获取参数.

链接的第一种格式如下: About.aspx?parameter = bla

但是由于需要,链接像
一样发送给用户
About.aspx?parameter%3Dbla

从链接 About.aspx?parameter%3Dbla ,我应该获取参数(bla).
当我尝试使用
正常获取参数时Request.QueryString ["parameter"]或HttpContext.Current.Request ["parameter"],它们返回null.

感谢您的提前答复..

I have to get a parameter from an encoded link .

The first format of link is like : About.aspx?parameter=bla

But because of a requirement the link is sended to the user like

About.aspx?parameter%3Dbla

From the link About.aspx?parameter%3Dbla , I should get the parameter(bla).
When I try to get parameter normally with
Request.QueryString["parameter"] or HttpContext.Current.Request["parameter"] , they returns null.

Thanks for the replies in advance..

推荐答案


public partial class About : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var myString = "parameter=\"bla\"";
        var base64EncodedString = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(myString));
        Response.Redirect("Default.aspx?temp=" + base64EncodedString);
    }
}


现在为Default.aspx.cs页面编码:
---------------------------------------


now code for Default.aspx.cs page:
---------------------------------------

public partial class _Default : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          var originalString = ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(Request.QueryString["temps"]));
          lblShowName.Text = Request.QueryString["parameter"];
      }
  }


这篇关于从编码链接ASP.NET获取参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 03:26