简体   繁体   English

将URL传递给查询字符串并从后面的c#代码中读取

[英]Pass URL into query string and read from c# code behind

I have html link which contain navigation URL like " https://mysiteURL.com/logout.aspx?ReturnUrl=https://www.yoursite.com/ " 我有html链接,其中包含“ https://mysiteURL.com/logout.aspx?ReturnUrl=https://www.yoursite.com/ ”等导航网址

Now functionality should be like when user click on above mention link it should redirect to logout page and then system will clear all session for user and redirect to “ReturnUrl “ value in our case it is https://www.yoursite.com . 现在功能应该是当用户点击上面提到链接它应该重定向到注销页面然后系统将清除用户的所有会话并重定向到“ReturnUrl”值在我们的情况下它是https://www.yoursite.com

Issue is when I try to read “ReturnUrl” from query sting it always return null value. 问题是当我尝试从查询中读取“ReturnUrl”时,它始终返回null值。 My code behind is look like below. 我的代码背后如下所示。

if (Request["ReturnUrl"] != null && !string.IsNullOrEmpty(Request["ReturnUrl"]))
{
     Response.Redirect(Request["ReturnUrl"],true);
}

Can anyone give the solution this? 有人能解决这个问题吗?

它看起来像你想要使用Request.QueryString["ReturnUrl"]而不是直接Request["ReturnUrl"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM