このコードで何か迷っていましたか?私がそれをテストするとき、私はファイルタイプを "File"としてPDFとして取得しません。ユーザーがデータベースからダウンロードした後にファイル形式を変更するのに手助けが必要
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ConnectionString);
conn.Open();
string pdffile = "select pdf from users where ID='" + TextBoxLic.Text + "'";
SqlCommand pdfcom = new SqlCommand(pdffile, conn);
SqlDataReader reader = pdfcom.ExecuteReader();
if (reader.Read())
{
Byte[] pdfData = (byte[])reader.GetValue(0);
Response.ContentType = "Application/pdf";
Response.AppendHeader("content-disposition", "attachment; filename=" + TextBoxLic.Text);
Response.BinaryWrite(pdfData);
Response.End();
conn.Close();
}
}
https://i.gyazo.com/8eb75d4e55bed17155690531841d80c7.png
あなたにはSQLインジェクションの脆弱性があります。 – SLaks