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. (Line numbers are included for reference only.)

01 public void ProcessRequest(HttpContext ctx) {
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(); 

+ Answer
+ Report
Total Preview: 2292

Copyright © 2024. Powered by Intellect Software Ltd