PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/Visual Studio 2008/CSASPNETMVCCustomActionFilter/Controllers/HomeController.cs

#
C# | 50 lines | 23 code | 4 blank | 23 comment | 0 complexity | 1c9c8e4816d61fd583885ec1e770609e 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;
23using System.Collections.Generic;
24using System.Linq;
25using System.Web;
26using System.Web.Mvc;
27
28namespace CSASPNETMVCCustomActionFilter.Controllers
29{
30    [HandleError]
31    public class HomeController : Controller
32    {
33        // Use declarative attribute to registetr the MessageModifier ActionFilter
34        [CSASPNETMVCCustomActionFilter.ActionFilters.MessageModifierActionFilter]
35        public ActionResult Index()
36        {
37            // The original value of Message data returned via ViewData collection
38            ViewData["Message"] = "Welcome to ASP.NET MVC!";
39
40            return View();
41        }
42
43        // Use declarative attribute to registetr the Logging ActionFilter
44        [CSASPNETMVCCustomActionFilter.ActionFilters.TextLogActionFilter(LogFileName = @"D:\temp\logs\mvc_action_filter.log")]
45        public ActionResult About()
46        {
47            return View();
48        }
49    }
50}