Ques:- Explain how to implement Fragment Cache
Asked In :-
CAFS, ACPL Systems, Agaram InfoTech, Secon Pvt Ltd, impressico business solutions, mahendra next wealth it india pvt ltd,
Right Answer:
To implement Fragment Cache in ASP.NET, you can use the `OutputCache` directive in your ASPX page or in a controller action in ASP.NET MVC. Here’s how to do it:
1. **In ASPX Page:**
```aspx
<%@ OutputCache Duration="60" VaryByParam="none" %>
```
2. **In ASP.NET MVC Controller:**
```csharp
[OutputCache(Duration = 60, VaryByParam = "none")]
public ActionResult YourAction()
{
return View();
}
```
This caches the output of the specified page or action for 60 seconds. Adjust the `Duration` and `VaryByParam` as needed for your application.
To implement Fragment Cache in ASP.NET, you can use the `OutputCache` directive in your ASPX page or in a controller action in ASP.NET MVC. Here’s how to do it:
1. **In ASPX Page:**
```aspx
<%@ OutputCache Duration="60" VaryByParam="none" %>
```
2. **In ASP.NET MVC Controller:**
```csharp
[OutputCache(Duration = 60, VaryByParam = "none")]
public ActionResult YourAction()
{
return View();
}
```
This caches the output of the specified page or action for 60 seconds. Adjust the `Duration` and `VaryByParam` as needed for your application.