我在尝试使用System.Security的加密代码时遇到运行时错误.我添加了对System.Security的引用,一切看起来不错,但我收到此错误:"编译器错误消息:CS0103:名称'ProtectedData'在当前上下文中不存在"
这是抛出错误的代码.
public static string EncryptString(SecureString input, string entropy)
{
byte[] salt = Encoding.Unicode.GetBytes(entropy);
byte[] encryptedData = ProtectedData.Protect(
Encoding.Unicode.GetBytes(ToInsecureString(input)),
salt,
DataProtectionScope.CurrentUser);
return Convert.ToBase64String(encryptedData);
}
Run Code Online (Sandbox Code Playgroud)
谢谢,山姆
我需要跟踪单击文件链接的时间,因此我构建了一个服务器端函数,在单击锚标记时写入SQL DB.它不会触发或打开文件.这是我的代码:
<a href="pdf/Access2013.pdf#zoom=100" runat="server" onServerClick="AccessFile_Click" target="_blank"><img src="img/pdf_icon.png" border="0" /></a>
Run Code Online (Sandbox Code Playgroud)
protected void AccessFile_Click(object sender, EventArgs e)
{
App_Code.bi.LogFileDownload("Access File", Session["UserID"].ToString());
}
Run Code Online (Sandbox Code Playgroud) 我需要在其上创建一个包含3个链接的简单视图(管理类型页面),我尝试将名为index的视图添加到名为Administration的目录中,但是当我尝试导航到它时,它会抛出资源未找到错误.我是来自Web Forms的MVC的新手,很抱歉,如果这是一个愚蠢的问题;)