PageRenderTime 42ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/CSASPNETMVCCustomActionFilter/Default.aspx.cs

#
C# | 43 lines | 17 code | 3 blank | 23 comment | 0 complexity | 944b6a5aaef482c1191bf534cd4bff71 MD5 | raw file
  1. /****************************** Module Header ******************************\
  2. * Module Name: MessageModifierActionFilter.cs
  3. * Project: CSASPNETMVCCustomActionFilter
  4. * Copyright (c) Microsoft Corporation.
  5. *
  6. * The CSASPNETMVCCustomActionFilter sample demonstrates how to use C# codes to
  7. * create custom ActionFilters for ASP.NET MVC web application. In this sample,
  8. * there are two custom ActionFilters, one is used for customizing ViewData(
  9. * before page view result get executed and rendered; another is used for
  10. * perform logging within the various events during the processing of custom
  11. * ActionFilters.
  12. *
  13. *
  14. * This source is subject to the Microsoft Public License.
  15. * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  16. * All other rights reserved.
  17. *
  18. * History:
  19. * * 10/10/2009 1:35 PM Steven Cheng Created
  20. ***************************************************************************/
  21. using System.Web;
  22. using System.Web.Mvc;
  23. using System.Web.UI;
  24. namespace CSASPNETMVCCustomActionFilter
  25. {
  26. public partial class _Default : Page
  27. {
  28. public void Page_Load(object sender, System.EventArgs e)
  29. {
  30. // Change the current path so that the Routing handler can correctly interpret
  31. // the request, then restore the original path so that the OutputCache module
  32. // can correctly process the response (if caching is enabled).
  33. string originalPath = Request.Path;
  34. HttpContext.Current.RewritePath(Request.ApplicationPath, false);
  35. IHttpHandler httpHandler = new MvcHttpHandler();
  36. httpHandler.ProcessRequest(HttpContext.Current);
  37. HttpContext.Current.RewritePath(originalPath, false);
  38. }
  39. }
  40. }