|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.Practices.Unity;
namespace Website.Core.Filters
{
public class BrowserDetectionFilter: IResultFilter
{
private IUnityContainer _container;
// Test for IoC
public BrowserDetectionFilter(IUnityContainer container)
{
_container = container;
}
#region IResultFilter Members
public void OnResultExecuted(ResultExecutedContext filterContext)
{
StringBuilder result = new StringBuilder();
result.Append("<div style=\"width:200px; border:1px #fff solid;color:#fff;margin:0 auto;padding:5px;\">");
result.Append(string.Format("<div><b>Browser Type</b>: {0}</div>", filterContext.HttpContext.Request.Browser.Browser));
result.Append(string.Format("<div><b>Version</b>: {0}</div>", filterContext.HttpContext.Request.Browser.Version));
result.Append("</div>");
filterContext.HttpContext.Response.Write(result.ToString());
}
public void OnResultExecuting(ResultExecutingContext filterContext) {}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.