public ActionResult StaticFile(string path, ResponseOptions responseOptions) { responseOptions ??= Options.DefaultStaticFileResponseOptions; HttpContextAccessor.HttpContext.Response.Headers.Add("Cache-Control", responseOptions.CacheHeader.ToString()); if (File.Exists(path)) { var file = new FileInfo(path); var extension = file.Extension; var contentType = MimeTypeMap.GetMimeType(extension); return(new FileStreamResult(File.OpenRead(path), contentType)); } return(new NotFoundResult()); }
public ActionResult Script(string path, ResponseOptions responseOptions = null) { path = Path.Combine(ScriptRoot, path); return(StaticFile(path, responseOptions)); }
public async Task <ContentResult> ViewAsync <T>(string viewName, T model = null, ExpandoObject viewBag = null, ResponseOptions responseOptions = null) where T : class { responseOptions ??= Options.DefaultPageResponseOptions; HttpContextAccessor.HttpContext.Response.Headers.Add("Cache-Control", responseOptions.CacheHeader.ToString()); var html = await RenderAsync(viewName, model, viewBag).ConfigureAwait(false); return(new ContentResult { ContentType = "text/html", Content = html, StatusCode = StatusCodes.Status200OK }); }