示例#1
0
        /// <summary>
        /// Render dynamic script file
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult Script(string fileName)
        {
            var model = _scriptService.GetScriptByName(fileName);

            if (model != null)
            {
                if (!WebUtilities.OutputNeedReCache(HttpContext.ApplicationInstance.Context, model.LastUpdate))
                {
                    return(Content(""));
                }

                return(Content(model.Content, _javascriptMime));
            }

            var requestPath = string.Format("/Resources/{0}.js", fileName);

            if (System.IO.File.Exists(HttpContext.Server.MapPath(requestPath)))
            {
                return(new FilePathResult(requestPath, _javascriptMime));
            }

            return(HttpNotFound());
        }