Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 1.11 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Change default ASP MVC Request Header to add your own values
  2. Cache-Control   private
  3. Connection  Close
  4. Content-Length  20901
  5. Content-Type    text/html; charset=utf-8
  6. Date    Fri, 20 Apr 2012 22:46:11 GMT
  7. Server  ASP.NET Development Server/10.0.0.0
  8. X-AspNet-Version    4.0.30319
  9. X-AspNetMvc-Version 3.0
  10.        
  11. X-Pingback: http://localhost:4912/pingback/xmlrpcserver
  12.        
  13. public class HttpHeaderAttribute : ActionFilterAttribute
  14.     {
  15.  
  16.         public string Name { get; set; }
  17.         public string Value { get; set; }
  18.  
  19.         public HttpHeaderAttribute(string name, string value)
  20.         {
  21.             Name = name;
  22.             Value = value;
  23.         }
  24.  
  25.         public override void OnResultExecuted(ResultExecutedContext filterContext)
  26.         {
  27.             filterContext.HttpContext.Request.Headers.Add(Name, Value);
  28.             base.OnResultExecuted(filterContext);
  29.         }
  30.  
  31.     }
  32.        
  33. [HttpHeader("X-Pingback","http://localhost:4912/pingback/xmlrpcserver")]
  34.         public ActionResult Index()
  35.         {
  36.             var allArticles = _repository.GetPublishedArticles(SortOrder.desc);
  37.             return View(allArticles);
  38.         }