Is there an echo equivalent in asp.net c #

I have php code that I converted to asp.net code. The PHP code simply echoes the answer that the client reads and interprets, however, in asp.net, the generated output is forced to be in html format, which is exactly what I use asp.net tags to output the output.

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

EDIT:

What I'm trying to do seems to be

// receive message data

echo "Some stuff"

My current aspx file for testing:

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

and the code behind has only one method:

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

Thank.

+3
source share
5 answers

The unit equivalent will be Response.Write:

Response.Write("some text");

, ASP.NET PHP . ASP.NET( MVC) .

, . - :

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

, Response, (, , ) . , HttpResponse, Response.Write().

+13

Response.Write("");

.aspx <%="string"%>

+5

, :

Response.Write(yourString);
+2

Response.Write() :

Response.Write("your text here");
+1

Yuck, Response.Write ( ) ASP . , , , - :

protected void Page_Load(object sender, EventArgs e)
{

    this.Controls.Add(new LiteralControl(Server.HTMLEncode("<h1>Welcome!</h1>")));
    //will actually print <h1>Welcome!</h1>, rather than Welcome! that bolded/centered/etc.
}

Or you can even add a literal control, label, etc. to the markup, and then just set the property Textto the code behind. This is a standard approach to solve this problem in an ASP environment.

+1
source

All Articles