XMLHttpRequest help

S

Steve

I'm trying to use XMLHttpRequest with asp.net
The tutorial that I have been following is based on PHP. All the client
script stuff was working fine, but now I'm trying to create the asp.net page
that will answer the request.

For testing, I just want to return a simple string. I thought I could do
something like this:
<code>

if(this.Request.QueryString.Count > 0 && this.Request.QueryString[0] ==
"GetImgData")
{
// this is a request from the ActiveX XmHttpRequest object trying
to get
// data about this image. I will return the big image URL, the
description
// and date/time information
Response.Write("testing!");
Response.Flush();
}
</code>

This does't work, it returns the full response with all the rendered HTML.
I'm sure I am doing this wrong, but I'm not sure why? Any ideas?

Thanks,
Steve
 
S

Steve

adding response.end didn't seem to have any effect at all, I tried it before
and after the flush() call.
I will look into the handler approach. Seems like it will be more work, but
sometimes that's a good thing.

Thanks!
Matt Berther said:
Hello Steve,

Im guessing that you have this code hosted inside an ASPX file. Given that,
you can go two routes:

1. Implement an IHttpHandler [1] for your XMLHttpRequest services, or
2. Add Response.End() after Response.Flush(). This instructs ASP.NET to stop
processing the current request.

[1] http://msdn.microsoft.com/library/d...html/frlrfSystemWebIHttpHandlerClassTopic.asp

--
Matt Berther
http://www.mattberther.com
I'm trying to use XMLHttpRequest with asp.net
The tutorial that I have been following is based on PHP. All the
client
script stuff was working fine, but now I'm trying to create the
asp.net page
that will answer the request.
For testing, I just want to return a simple string. I thought I could
do
something like this:
<code>
if(this.Request.QueryString.Count > 0 &&
this.Request.QueryString[0] ==
"GetImgData")
{
// this is a request from the ActiveX XmHttpRequest object
trying
to get
// data about this image. I will return the big image URL,
the
description
// and date/time information
Response.Write("testing!");
Response.Flush();
}
</code>
This does't work, it returns the full response with all the rendered
HTML. I'm sure I am doing this wrong, but I'm not sure why? Any
ideas?

Thanks,
Steve
 
B

Bruce Barker

try:

if(this.Request.QueryString.Count > 0 && this.Request.QueryString[0] ==
"GetImgData")
{
Response.Clear(); // remove all buffered content
Response.Write("testing!");
Response.End(); // don't write any more
}

-- bruce (sqlwork.com)
 
S

Steve

thanks for the post, that didn't do it either. I still get the whole page
back.
Bruce Barker said:
try:

if(this.Request.QueryString.Count > 0 && this.Request.QueryString[0] ==
"GetImgData")
{
Response.Clear(); // remove all buffered content
Response.Write("testing!");
Response.End(); // don't write any more
}

-- bruce (sqlwork.com)

Steve said:
I'm trying to use XMLHttpRequest with asp.net
The tutorial that I have been following is based on PHP. All the client
script stuff was working fine, but now I'm trying to create the asp.net
page
that will answer the request.

For testing, I just want to return a simple string. I thought I could do
something like this:
<code>

if(this.Request.QueryString.Count > 0 && this.Request.QueryString[0] ==
"GetImgData")
{
// this is a request from the ActiveX XmHttpRequest object trying
to get
// data about this image. I will return the big image URL, the
description
// and date/time information
Response.Write("testing!");
Response.Flush();
}
</code>

This does't work, it returns the full response with all the rendered HTML.
I'm sure I am doing this wrong, but I'm not sure why? Any ideas?

Thanks,
Steve
 
S

Steve

ah, this does work. I wasn't building the correct project. Thanks for the
help, I'm off and tunning now! ;)
Bruce Barker said:
try:

if(this.Request.QueryString.Count > 0 && this.Request.QueryString[0] ==
"GetImgData")
{
Response.Clear(); // remove all buffered content
Response.Write("testing!");
Response.End(); // don't write any more
}

-- bruce (sqlwork.com)

Steve said:
I'm trying to use XMLHttpRequest with asp.net
The tutorial that I have been following is based on PHP. All the client
script stuff was working fine, but now I'm trying to create the asp.net
page
that will answer the request.

For testing, I just want to return a simple string. I thought I could do
something like this:
<code>

if(this.Request.QueryString.Count > 0 && this.Request.QueryString[0] ==
"GetImgData")
{
// this is a request from the ActiveX XmHttpRequest object trying
to get
// data about this image. I will return the big image URL, the
description
// and date/time information
Response.Write("testing!");
Response.Flush();
}
</code>

This does't work, it returns the full response with all the rendered HTML.
I'm sure I am doing this wrong, but I'm not sure why? Any ideas?

Thanks,
Steve
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top