cepriego
cepriego

Reputation: 883

How to respond a HTTPGET calling in ASP?

I’m using a SMS service which forwards the received SMSs to my web page by calling my URL using get method. My webpage should respond with an ‘Ok’ in plain text, however I don’t know how to do that, can you give me any idea?

Upvotes: 0

Views: 90

Answers (2)

mattmanser
mattmanser

Reputation: 5796

You should use a generic handler (ashx) to do this, in a generic handler:

public class Handler1 : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        //your code here
        context.Response.ContentType = "text/plain";
        context.Response.Write("OK");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

The reason to do it in a generic handler is that you avoid the entire page lifecycle that aspx pages have.

If you've want to get up and running fast in a aspx page, simply do this in something like page_load:

        Response.Clear();
        Response.Write("OK");
        Response.End();

Upvotes: 1

Shadow Wizard
Shadow Wizard

Reputation: 66388

In the Page_Load event of code behind:

Response.Clear();
Response.Write("Ok");
Response.End();

Upvotes: 1

Related Questions