【发布时间】:2017-07-20 10:28:54
【问题描述】:
我试图通过查询字符串将值传递到另一个页面,但它发送它们为空。为什么?
<a href='UpcomingNotifications.aspx?OrgID=<%# SharedUtility.EncryptURL("10") %>&RoleID=<%# SharedUtility.EncryptURL("1") %>'
target="_blank"
class="pull-right"
style="margin-top: -44px; margin-right: 6px;">
<asp:Label ID="lblUpcomingWorks" runat="server"
CssClass="btn btn-sm- btn-danger"
Text=" Upcoming Works Openings" Visible="false" />
</a>
输出: http://localhost:5297/forms/admin/UpcomingNotifications.aspx?OrgID=&RoleID=
更新:加密方式:
public static String EncryptURL(string strData)
{
try
{
if (!String.IsNullOrEmpty(strData))
{
SHA1Managed shaM = new SHA1Managed();
Convert.ToBase64String(shaM.ComputeHash(Encoding.ASCII.GetBytes(strData)));
Byte[] encByteData;
encByteData = ASCIIEncoding.ASCII.GetBytes(strData);
String encStrData = Convert.ToBase64String(encByteData);
return encStrData;
}
else
{
return "";
}
}
catch (Exception) { return ""; }
}
【问题讨论】:
-
SharedUtility.EncryptURL()方法返回哪种值?尝试使用<%= SharedUtility.EncryptURL("n") %>来呈现文字字符串。 -
它返回字符串数据,但在我的情况下它返回空字符串
-
我试过你说的但还是空
-
SharedUtility.EncryptURL()在其他场合是否正常工作或返回正确的值?最好在这里显示方法代码。<%# ... %>指令通常用于与数据绑定控件进行数据绑定。 -
是的,我正在绑定控件,但为简单起见,我编写了 10 和 1,它们也作为空字符串传递。
标签: c# asp.net .net c#-4.0 webforms