Introduction
This article explains the Auto Refresh Partial View in the ASP .NET Web API. It is something that, used together, gives a way to refresh a partial view in a specified time period. Here we use three images that will change on refreshing the partial view in 2 seconds.
Follow these procedures for using Auto refresh Partial View in Web API.
Step 1
Create a web API Application.
-
Start Visual Studio 2012.
-
From the start window select "New Project".
-
In the Template Window select "Installed" -> "Visual C#" -> "Web".
-
Select "ASP.NET MVC 4 Web Application" and click on "OK".

From the "MVC4 Project" window select "Web API".

Step 2
Create a Model Class "Show.cs".
-
In the "Solution Explorer".
-
Right-click on the "Modelfolder" -> "Add" -> "Class".

Select the class and click on the "OK" button.
Add this code to this class.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace PageRefresh.Models
- {
- public class Show
- {
- public int id { get; set; }
- public string Name_alter { get; set; }
- public string Image_src { get; set; }
- }
- public class IRepository
- {
- public static List<Show> GetData()
- {
- List<Show> detail = new List<Show>
- {
- new Show
- {
- id = 1,
- Name_alter = "Mudita",
- Image_src = "Images/Jellyfish.jpg"
- },
- new Show
- {
- id = 2,
- Name_alter = "Tayna",
- Image_src ="Images/Tulips.jpg"
- },
- new Show
- {
- id = 3,
- Name_alter = "Neeju",
- Image_src = "Images/Lighthouse.jpg"
- }
- };
- return detail;
- }
- }
- }
Step 3
Open "HomeController".
-
In the "Solution Explorer".
-
Select "Controller folder" -> "Home Controller".






Join the conversation! Your thoughts help the community grow.