Cheung
Cheung

Reputation: 15552

How to disable ASP.NET render default html tag?

For some reason, i have to make a aspx page to let iphone/android to Post form. After the data processing of request.form , i have response a JSON string in plain text. However *.aspx will enforce to render html,head,body tag,so how can i disable it?

I cannot use ashx, because the mobile have to post image via form, as i search the answer by google ,ashx cannot handle the http post files.

Edit: As SLaks said, ashx can handle POST file using "context.Request.Files" and it works.

Upvotes: 0

Views: 460

Answers (3)

SLaks
SLaks

Reputation: 887275

You are wrong.

ASHX files can handle HTTP POSTs.

To answer the question, you can delete all of the content in the ASPX file. ASPX files do not need to have any content at all (other than the <%@ Page %> directive)

Upvotes: 6

Joel Coehoorn
Joel Coehoorn

Reputation: 415620

When processing the post, use this code:

Response.Clear();
Response.ContentType = "text/json";

Response.Write("your json goes here");

Response.End();

Upvotes: 3

BrunoLM
BrunoLM

Reputation: 100322

Clear the Response, set the content-type since it's json, add your json then end it:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Clear();
    Response.ContentType = "text/json";
    Response.Write("your json");
    Response.End();
}

Outputs exactly

your json

Upvotes: 1

Related Questions