write a string contain html tag on the page to create a html table in asp.net mvc

I use this code to return an string from my action :

    public ActionResult Index()

        string List = "";       
        List = "<table><tr><td>Ali</td></tr></table>";
        ViewData["List"] = List;
        return View();


and this is my view :

<%: ViewData["List"] %>

but instead to create a table when i browse the page , i see that the string "<table><tr><td>Ali</td></tr></table>" wrote on it. I use the firebug and see its html code . but i saw something like this :


Is there any body out there to help me?

Thansk Regards


This is because you use the HtmlEncode tag

Change the <%: to <%=

will be come

<%= ViewData["List"] %>

and do not forget to HtmlEncode your data only to avoid any injection.

Need Your Help

Implement PHP logic to jQuery

javascript php jquery

In a system I have 3 users, Ben, Shane and Payne, the site functions normally for all users and also have same Menu system. However I am tasked to add one Menu item from core and be visible only fo...

Why does Gradle disregard release{} and implement a rule on debug build as well?

android-studio android-gradle

I am not sure if this happened before, but I think it happened after the recent updates of Android Studio and its Gradle.