title: How to return Json data from MVC Controller in C#
body: <p>I am using a Repository pattern with Entity Framework, When i run my code instead of Json Data I am getting <strong>-> System.Collections.Generic.List`1[MovieInfo.Core.Models.Models.User]</strong></p>
  
  <p><strong>Repository</strong></p>
  
  <pre><code>public interface IRepository&lt;T&gt; where T : class
  {
      IEnumerable&lt;T&gt; Get();
  
      T GetDetails(Guid Id);
  
      void Insert(T data);
  
      void Delete(T data);
  
      void Update(T data);
  
      void Save();
  }
  
  public GenericRepository()
          {
              context = new Entities();
              dbEntity = context.Set&lt;T&gt;();
          }
  </code></pre>
  
  <p><strong>Services</strong></p>
  
  <pre><code>public class TestService : ITestService
      {
          public TestService(
             IRepository&lt;User&gt; userRepository
             )
          {
              _userRepository = userRepository;
          }
  
          private readonly IRepository&lt;User&gt; _userRepository;
  
          public IEnumerable&lt;User&gt; Get()
          {
  
              var result = _userRepository.Get();
  
              return result;
          }
      }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public class HomeController : Controller
  {
      public HomeController(ITestService testService)
      {
          _testService = testService;
      }
  
      private readonly ITestService _testService;
  
      public IEnumerable&lt;User&gt; Index()
      {
          var result = _testService.Get();
  
          return result;
      }
  }
  </code></pre>
  
  <p>I found some solution on here (StackOverflow) that I need to add WebApiConfig, I added as below but it also not work. I am getting the output 
  <strong>System.Collections.Generic.List`1[MovieInfo.Core.Models.Models.User]</strong></p>
  
  <pre><code> public static class WebAppConfig
  {
      public static void Register(HttpConfiguration config)
      {
          config.Formatters.Remove(new XmlMediaTypeFormatter());
  
          config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
  
          config.Formatters.XmlFormatter.SupportedMediaTypes.Add(new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data"));
  
          config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{action}/{id}",
              defaults: new
              {
                  id = RouteParameter.Optional
              }
          );
      }
  }
  </code></pre>
  
  <p><strong>Here is my Git Repository Link</strong> 
  <a href="https://github.com/Harshk16/MovieInfo" rel="nofollow noreferrer">https://github.com/Harshk16/MovieInfo</a></p>
  
  <p>Please help me out how to get output in Json Format</p>