Skip to content

Instantly share code, notes, and snippets.

//Authorization Filter
[Authorize]
public string authorization()
{
return "Check Authorization Filter!";
}
//Action Filter
[OutputCache(Duration = 10)]
public string CurrentTime()
{
return DateTime.Now.ToString("T");
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace FiltersDemo.Controllers
{
public class HomeController : Controller
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace FiltersDemo.Controllers
{
public class HomeController : Controller
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace FiltersDemo.Controllers
{
public class HomeController : Controller
{
public ActionResult Student(String Name)
{
var input = Server.HtmlEncode(Name);
return Content(input);
}
public ActionResult Student()
{
var input = "This is another Studetn Action Method";
return Content(input);
public ActionResult Student(String Name)
{
var input = Server.HtmlEncode(Name);
return Content(input);
}
[HttpGet]
public ActionResult Student()
{
var input = "This is another Studetn Action Method";
[HttpPost]
public ActionResult PostAction()
{
return View("Index");
}
[HttpPut]
public ActionResult PutAction()
{
return View("Index");
[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)]
public ActionResult GetAndPostStudentAction()
{
return View();
}
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
namespace DataBaseDemo.Models
{
public class Student
{