Created
          November 22, 2016 12:44 
        
      - 
      
- 
        Save StefanoChiodino/25affa33580163d6bafbfe1043401c12 to your computer and use it in GitHub Desktop. 
    A controller that caches only get requests
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class CachedGetController : ControllerBase | |
| { | |
| [HttpGet] | |
| [OutputCache(Duration = 600)] | |
| public override ActionResult Index(RenderModel model) | |
| { | |
| return base.Index(model); | |
| } | |
| [HttpPost] | |
| public ActionResult Index(RenderModel model, object obj = null) | |
| { | |
| return base.Index(model); | |
| } | |
| } | |
| public abstract class ControllerBase : SurfaceController, IRenderMvcController | |
| { | |
| public virtual ActionResult Index(RenderModel model) | |
| { | |
| return this.CurrentTemplate(model); | |
| } | |
| private ActionResult CurrentTemplate(RenderModel model) | |
| { | |
| var template = this.ControllerContext.RouteData.Values["action"].ToString(); | |
| return this.View(template, model); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment