Skip to content

Instantly share code, notes, and snippets.

@c1982
Created February 17, 2011 01:55
Show Gist options
  • Save c1982/830783 to your computer and use it in GitHub Desktop.
Save c1982/830783 to your computer and use it in GitHub Desktop.
using System.Web.Mvc;
namespace MvcApplication1.Models
{
public class CheckBrowserAttribute : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var userAgent = filterContext.HttpContext.Request.ServerVariables["HTTP_USER_AGENT"];
if (userAgent.IndexOf("MSIE") != -1)
filterContext.Result = new ContentResult()
{ Content = "<script>alert('YASAK! FireFox veya Chrome kullanın.');</script>" };
base.OnActionExecuting(filterContext);
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
base.OnResultExecuted(filterContext);
}
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
base.OnResultExecuting(filterContext);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment