clearing everything in the response and sending my own text

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

Hi,

there is a aspx page in my web application, in certain conditions, I don't
want its response to carry all the html that exists in the design view,
instead I want to response to contain *only* some short text that I want to
send down as response. The Response.Clear () is not doing this job. Plz
recommend a way.
Coding in visual studio 2k5/Win7rc.

thanks,

...ab
http://joehacker.blogspot.com
 
I cant see how response clear is not doing its job, I mean is should.
When you say just test, do you mean you don't event want
<html><head><body>??
if so you should use a ashx page, a ashx page is much like a aspx page but
it is used for rendering other formats like jpg gif pdf doc xls, give it the
correct content type and it will render it, you don't need to response clear
because its just rendering what you want with out and html specific stuff
 
Hi,
I cant see how response clear is not doing its job, I mean is should.
When you say just test, do you mean you don't event want
<html><head><body>??

Yea, everything.
if so you should use a ashx page, a ashx page is much like a aspx page but

if I had an option of making a new page just for this purpose I would make a
new aspx page and remove all the design time html stuff and just code the
server side code behind stuff.
The thing is that I have a page which already is performing some nice
functionality, its got bound drop downs and a datalist control etc. I just
wanted to make a ajax call (XMLHttpRequest) from within that page and
request some functionality. Now I noticed that along the response that I
write through Response.Write(), a lot of html was also coming down the
wires, which ofcourse I can write a lil javascript code to get rid of, but
wont be satisfied with it. So just for the XMLHttpRequest call I was
thinking hey I should just get rid of all the html that's coming along, but
it didn't work.

I was searching google, but havnt found much, I think it cant be done (the
way I want)? I was hoping there should be just a simple event somewhere in
the life cycle of an aspx page which would just allow me to get rid of all
the response that has been contructed so far, or maybe, don't even do any
aspx side parsing :) and just leave everything in the response to me.

last choice would be to do some easy refactoring of the page1 and than
through the page2 (which I will make specifically for XMLHttpRequest) use
the data queries that I need from the refactored code.

thanks,
...ab
http://joehacker.blogspot.com
 
as you are probably using buffered responses, the clear has little
effect. you need to call Response.End() to prevent more text being
written. try:

Response.Clear();
Response.Wtite("only text");
Response.End();

-- bruce (sqlwork.com)
 
Back
Top