Interview question

G

Gopal Krish

I was asked this question in an interview.

How can you display the contents of an ASP page (from another web
server) in a aspx page, ie, first half of the screen will display
contents from asp and the other half will be from the current aspx
page. Using frames is not an option.

Any thoughts? (Is this even possible?)
 
S

Sahil Malik

It is possible, right of the top of my head you could always HttpRequest a
page and simply stream it to a string that is coded as
<%=thisstringwillgettherepresentation%>. You might have to clean the body
tag etc. out of it, but it is certainly possible. I am sure if I thought
about it a lil' bit more I could come up with more elegant options.

But I wanna add - yes it is possible, but why in the world would you wanna
do it?

- Sahil Malik
http://www.dotnetjunkies.com/weblog/sahilmalik
 
L

Lloyd Dupont

I'm not sure about what you mean....

anyway what about:
<PRE><% Response.Write(contentString); %></PRE>
 
J

John Timney \(Microsoft MVP\)

Request the page using the net httprequest class and output the resulting
string to a panel control

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
 
G

Gopal Krish

I couldn't believe someone can ask this in an interview. There is so
much more useful than this one to ask in the interview.

Thanks everone. I'll play with http request class and understand it
better.
 
G

Gopal Krish

John,

I looked at the httprequest class and couldn't find any method to
request a page from an external web server.

Could you pls let me know the method name?
 
G

Gopal Krish

The .NET documentation on HttpRequest talk only about dealing with the
current web server. There is not much information anywhere on google
on requesting web pages from external web servers,

Finally after much trial and error and with few rate samples, I have
done it. Thought I'll post it here. incase anyone needs it.

HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create("http://www.yahoo.com");
HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
StreamReader streamReader = new
StreamReader(HttpWResp.GetResponseStream());
string s = streamReader.ReadToEnd();
streamReader.Close();
HttpWResp.Close();
Label myL = new Label();
myL.Text = s;
Panel1.Controls.Add(myL);
 
K

Kevin Spencer

I couldn't believe someone can ask this in an interview. There is so
much more useful than this one to ask in the interview.

Hey, you had to ask someone else for the answer. Offhand, I would say that
it is a very good question, in that it identifies the level of knowledge of
the interviewee. You, for example, were unable to answer it during the
interview.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
E

Eric Gibson

Gopal said:
I couldn't believe someone can ask this in an interview. There is so
much more useful than this one to ask in the interview.

Thanks everone. I'll play with http request class and understand it
better.

I've been using "screen scraping" for the past couple days actually. It's
pretty useful...

Eric
 
J

John Timney \(Microsoft MVP\)

A question like this would test your understanding of the framework and its
underlying classes, methods and namespaces, rather than your ability to
code.

I ask much harder questions than this when I interview to help determine the
depth of technical understanding that the candidate has. Many people can
use an IDE, but not many understand what it does behind the scenes, and how
the ASP pipeline works.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top