Source

Inside.Util / Web / MvcControllerBase.cs

Full commit
using System;
using System.Web.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.Mvc;

using NLog;

using Inside.Util;
using Inside.Util.Json;
using Inside.Util.Sql;

namespace Inside.Util.Web {
	public abstract class MvcControllerBase : Controller {
		protected bool Debugging { get; private set; }

		dynamic _useragent;
		protected dynamic UserAgent {
			get {
				if(null == this._useragent) {
					this._useragent = new DyObj();
					this._useragent.name = this.Request.Browser.Browser;
					this._useragent.version = decimal.Parse(this.Request.Browser.Version);
				}

				return this._useragent;
			}
		}

		protected override void Initialize(System.Web.Routing.RequestContext requestContext) {
			base.Initialize(requestContext);

			this.Debugging = requestContext.HttpContext.IsDebuggingEnabled;
		}

		protected ActionResult ViewAsFile(string view_name, string content_type, object model, string file_download_name, string master_name = null) {
			if(null != model) {
				this.ViewData.Model = model;
			}

			return new ViewAsFileResult { FileDownloadName = file_download_name, ContentType = content_type, MasterName = master_name, ViewData = this.ViewData, TempData = this.TempData, ViewName = view_name };
		}
	}
}