The difference between ASP. NET and ASP in the background directly splicing output

Source: Internet
Author: User

The previous time wanted to directly in MVC in one of the most stupid way to output a script, so think of Response.Write, but later found very problematic, because the output in this way is directly in the first line of the page appears, so the script function is not called at all, so the Html.raw ()

Today, we observed that the traditional ASP. NET and MVC use the Response.Write output, and found that there are some differences between the two in the occurrence position.

ASP. NET MVC

   Public ActionResult Index ()        {            var a = 1;            var b = 2;            Response.Write ("<a onclick=a ('" + A + "', '" + B + "') > Baidu </a>");            return View ();        }

Output:

asp

protected void Page_Load (object sender, EventArgs e)    {        var a = 1;        var B = 2;        Response.Write ("<a onclick=a ('" + A + "', '" + B + "') > Baidu </a>");    }

Output:

So using Response.Write in MVC simply doesn't get the function in JS, but ASP. NET can

The difference between ASP. NET and ASP in the background directly splicing output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.