我有以下代码:AbsolutePath与查询字符串
if (Request.Url.AbsolutePath == "/Guidance.aspx")
{
if (Request.IsSecureConnection)
{
Reponse.Redirect("http://www.example.com/Guidance.aspx");
}
return;
}
的事情是,指导可以用它查询字符串。我喜欢重定向到相同的页面名称并追加查询字符串。还没有找到办法做到这一点。
if (Request.Url.AbsolutePath == "/Guidance.aspx?id='vid09'")
{
if (Request.IsSecureConnection)
{
Reponse.Redirect("http://www.example.com/Guidance.aspx?id='vid09'");
}
return;
}
我怎样才能简化上面的代码来处理任何查询字符串。
查看字符串是否包含'Guidance.aspx'preg_match('/(Guidance.aspx)/')',然后将所有'?'后面的内容放入变量中,并在其重定向时将其追加到末尾 – Luke
使用原始网址提取查询字符串,只是将相同的查询字符串附加到RedirectUrl,没有简单的方法处理C#中的查询字符串,我记得.. –
也许你可以使用IIS URL重写? http://www.iis.net/downloads/microsoft/url-rewrite –