情况
我正在开发一个应用程序,我可以在其中创建一个包含 X 个项目的网格,并且每个项目都有一个打印按钮。单击此打印按钮可以调用 ajax 函数,该函数将网格项的 ID 传递给控制器。我根据该 ID 检索相关数据,然后将其下载到 excel 文件中。(具体项目的检索尚未完成)
到目前为止我所拥有的
到目前为止,我已经有了下载 excel 文件的基本代码,以及我的 grid 。
问题
我面临的问题是,如果我单击“打印”按钮……什么也没有发生,即使我的exporttoexcel 函数中有一个断点,也会向我显示该函数已输入,我可以单步执行,尽管没有错误,但什么也没发生。但是,我添加了调用相同函数的随机按钮,当我单击该按钮时,下载了 excel 文件。因此,我认为这个问题与 aJax 有关。
代码
<input type="button" value="Test" onclick="location.href='@Url.Action("ExportToExcel", "Profile")'" />
Run Code Online (Sandbox Code Playgroud)
这是下载文件的代码。这是我添加的一个简单按钮。
function ExportToExcel(id) {
$.ajax({
type: "POST",
url: "@Url.Action("ExportToExcel", "Profile")",
data: { "id": id },
dataType: "json"
});
}
Run Code Online (Sandbox Code Playgroud)
这是我想要工作的功能,但它不起作用,我看不出我有什么问题。
导出到 Excel 代码
public void ExportToExcelx()
{
var products = new System.Data.DataTable("teste");
products.Columns.Add("col1", typeof(int));
products.Columns.Add("col2", typeof(string));
products.Rows.Add(1, "product 1");
products.Rows.Add(2, "product 2");
products.Rows.Add(3, "product 3");
products.Rows.Add(4, "product …Run Code Online (Sandbox Code Playgroud) 我有以下 C# 客户端代码来检查 SSL 通信中的传入证书(使用 WCF):
private bool ValidateClientCertificate(System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
_certificateValid = sslPolicyErrors == System.Net.Security.SslPolicyErrors.None ? true : false;
return true;
}
Run Code Online (Sandbox Code Playgroud)
进入该方法时,我可以看到 sslPolicyErrors 设置为RemoteCertificateNameMismatch?
我已经创建了这样的服务器证书: