Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent of echo in asp.net c#

Tags:

c#

asp.net

I have a php code which I have converted to asp.net code. The PHP code simply echoes a response which a client reads and interpretes, however in asp.net, the generated output is forced to be in html format -- which is precisely because I'm using asp.net labels to print the output.

Is there a way I can achieve the same thing as the echo in php or is there a very lightweight code that can help me parse the html text properly?

EDIT:

What I'm trying to do is like

//get post data

echo "Some stuff"

My current testing aspx file is:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="grabber.aspx.cs" Inherits="qProcessor.grabber" %>

and the code behind has just one method:

    protected void Page_Load(object sender, EventArgs e)
    {
        //this.Response.Write("Welcome!");
    }

Thanks.

like image 971
Chibueze Opata Avatar asked Nov 27 '22 22:11

Chibueze Opata


1 Answers

The one-for-one equivalent would be Response.Write:

Response.Write("some text");

That said, ASP .NET and PHP are very different frameworks. With ASP .NET (including the MVC framework) there is rarely a need to write directly to the response stream in this manner.

One such case would be if you wanted to return a very lightweight response. You could do something like this:

Response.ContentType = "text/xml";
Response.Write("<root someAttribute = 'value!' />");

Any method other than using Response directly can (and probably will) alter the output. So in short - if you want to just dump raw data into the HttpResponse, you'll want to use Response.Write().

like image 66
Yuck Avatar answered Dec 13 '22 14:12

Yuck