good morning: I have the following code:
generic handler
public void ProcessRequest(HttpContext context)
{
string nombreArchivo,tipo;
// int id = 12725; NOTA:"Si hago asi no marca error y si me muestra el pdf"
int id = int.Parse(context.Request.QueryString["Id"]);
using (SqlConnection con = new SqlConnection(myconsql))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT nomb, ruta, tipo FROM Cat WHERE id=@Id";
cmd.Parameters.AddWithValue("@Id", id);
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
ruta = (byte[])sdr["ruta"];
tipo = sdr["tipo"].ToString();
nombArchivo = sdr["nombArchivo"].ToString();
}
con.Close();
}
}
context.Response.Buffer = true;
context.Response.Charset = "";
if (context.Request.QueryString["download"] == "1")
{
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + nombArchivo);
}
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.ContentType = "application/pdf";
context.Response.BinaryWrite(ruta);
context.Response.Flush();
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
mark this error:
Value can not be null. Parameter name: String Line 23:
int id = int.Parse (context.Request.QueryString ["Id"]);
So I have it in source asp.net c #:
table.append("<tr id='row_" + i + "'><td name='id'>" + Data[i].id + "</td> + "
"<td style='display: none'>" + Data[i].ruta + "</td>" + " <td style='display: none'>" + Data[i].tipo + "</td>" + "<td name='nombArchivo'>" + " <a href='http://localhost:25429/FileCS.ashx?Id='" + Data[i].id + "target='_blank='_blank'>" + Data[i].nombArchivo + "</a></td></td></tr>");
and when I run it I get that error, but without changing it if I assign a specific id in generic if you show it to me, I'll be doing something wrong in the html table source ?????