PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms 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
22using System.Web;
23using System.Web.Mvc;
24using System.Web.UI;
25
26namespace CSASPNETMVCCustomActionFilter
27{
28    public partial class _Default : Page
29    {
30        public void Page_Load(object sender, System.EventArgs e)
31        {
32            // Change the current path so that the Routing handler can correctly interpret
33            // the request, then restore the original path so that the OutputCache module
34            // can correctly process the response (if caching is enabled).
35
36            string originalPath = Request.Path;
37            HttpContext.Current.RewritePath(Request.ApplicationPath, false);
38            IHttpHandler httpHandler = new MvcHttpHandler();
39            httpHandler.ProcessRequest(HttpContext.Current);
40            HttpContext.Current.RewritePath(originalPath, false);
41        }
42    }
43}