Question:You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a class that implements the IHttpHandler interface. You implement the ProcessRequest method by using the
following code segment:
01 public void ProcessRequest(HttpContext ctx) {
02 â–º
03 }
You need to ensure that the image named Alert.jpg is displayed in the browser when the handler is requested.
Which code segment should you insert at line 02?
A StreamReader sr = new StreamReader(File.OpenRead(ctx.Server.MapPath("Alert.jpg")));
ctx.Response.Pics(sr.ReadToEnd());
sr.Close();
B StreamReader sr = new StreamReader(File.OpenRead(ctx.Server.MapPath("Alert.jpg")));
ctx.Response.Pics("image/jpg");
ctx.Response.TransmitFile(sr.ReadToEnd());
sr.Close();
C ctx.Response.ContentType = "image/jpg";
FileStream fs = File.OpenRead(ctx.Server.MapPath("Alert.jpg"));
int b;
while ((b = fs.ReadByte()) != -1) {
ctx.Response.OutputStream.WriteByte((byte)b);
}
fs.Close();
D ctx.Response.TransmitFile("image/jpg");
FileStream fs = File.OpenRead(ctx.Server.MapPath("Alert.jpg"));
int b;
while ((b = fs.ReadByte()) != -1) {
ctx.Response.OutputStream.WriteByte((byte)b);
}
fs.Close();