How do you create a response page with no HTML in ASP.Net?

W

wptpro

I need to create an aspx page that returns a data string with no html
code. In ASP it would be easy by not including any HTML code and then
doing a repsonse.write "my data string". How do i do this in .net? It
seems to always include html even if I remove it from teh code behind
page.
 
E

Edwin Knoppert

Try in page_load or so:

Response.clear
Response.clearHeaders
Response.clearContent

Response.Write( "sgefddfdg" )

Response.close
Response.End
 
J

Joerg Jooss

Edwin said:
Try in page_load or so:

Response.clear
Response.clearHeaders
Response.clearContent

Response.Write( "sgefddfdg" )

Response.close
Response.End

A HttpHandler would be a cleaner solution if all you want to do is dump
raw data back to the client.

Cheers,
 
W

wptpro

any tips or help on how to do that would be great. I couldt ge the
example above to work. I just need to call an aspx page, do some
program logic, then return a data string. I'm replacing an http post
to a cgi app.
 
K

Kevin Spencer

If you remove all the template code, leaving a blank template, and
Response.Write anything that is not HTML, there will be no HTML in the
Response.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
 
J

Joerg Jooss

any tips or help on how to do that would be great. I couldt ge the
example above to work. I just need to call an aspx page, do some
program logic, then return a data string. I'm replacing an http post
to a cgi app.

See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide
/html/cpconcreatinghttphandlers.asp for an introduction to HttpHandlers.

As other users pointed out, you can use a ASP.NET page as well, but you
need to make sure that it doesn't contain any markup and you pay the
overhead of the page lifecycle at runtime.

Cheers,
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top