Anamnian Anamnian - 1 year ago 100
ASP.NET (C#) Question

Content doesnt exists in current context

I got a error (CS0103 C# The name 'Content' does not exist in the current context) in code below:

public ActionResult getsomething()
var res = "something";
return Content(res);}

Do u have any idea i can fix that?

Answer Source

Try use System.Web.Mvc.Controller Content() function instead System.Web.UI.WebControls.Content Class


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebApplication2.Controllers
    public class HomeController : Controller
        public ActionResult Index()
            return Content("xxxxx");

Its work fine
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download