Friday, September 2, 2011

ASP.NET/ASPX How to return a simple non-html response

After too much time waste for this issue, there is a trivial solution that many ppl miss.
Instead of trying to do
Response.Clear() / ClearContent() / ClearHeaders(), like many web solutions show you - but don't work !
Just go to the aspx page that was created by the wizard (not the code-behind .cs page), delete everything except for the first directive tag telling the server to parse the page in the aspx engine :
e.g.,
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ajax.aspx.cs" Inherits="Appcident.ajax" %>

and in your code behind, just return a response, like:

Response.Write(pageResponse);
Response.AddHeader("Connection", "close");

No comments:

Post a Comment

Feel free to comment. No links/URLs allowed in comments.