public static void Filename_Roundtrip() { var cd = new ContentDisposition(); Assert.Null(cd.FileName); Assert.Empty(cd.Parameters); cd.FileName = "hello"; Assert.Equal("hello", cd.FileName); Assert.Equal(1, cd.Parameters.Count); Assert.Equal("hello", cd.Parameters["filename"]); Assert.Equal("attachment; filename=hello", cd.ToString()); cd.FileName = "world"; Assert.Equal("world", cd.FileName); Assert.Equal(1, cd.Parameters.Count); Assert.Equal("world", cd.Parameters["filename"]); Assert.Equal("attachment; filename=world", cd.ToString()); cd.FileName = null; Assert.Null(cd.FileName); Assert.Empty(cd.Parameters); cd.FileName = string.Empty; Assert.Null(cd.FileName); Assert.Empty(cd.Parameters); }
public void TestArgumentExceptions() { var disposition = new ContentDisposition(); Assert.Throws <ArgumentNullException> (() => disposition.Disposition = null, "Setting the disposition to null value should throw."); Assert.Throws <ArgumentException> (() => disposition.Disposition = string.Empty, "Setting the disposition to an empty value should throw."); Assert.Throws <ArgumentException> (() => disposition.Disposition = "žádost", "Setting the disposition to a non-ascii value should throw."); Assert.Throws <ArgumentException> (() => disposition.Disposition = "two atoms", "Setting the disposition to multiple atom tokens should throw."); Assert.Throws <ArgumentNullException> (() => disposition.ToString(null, Encoding.UTF8, true)); Assert.Throws <ArgumentNullException> (() => disposition.ToString(FormatOptions.Default, null, true)); }
public async Task <IActionResult> DownloadAttachment(int id) { var comment = await _commentRepository.FindByIdAsync(id); // return File(comment.File, comment.FileMimeType, comment.FileURL); try { if (comment?.FileMimeType != null) { ContentDisposition cd = new ContentDisposition { FileName = comment.FileURL, Inline = true }; Response.Headers["Content-Disposition"] = cd.ToString(); return(File(comment.File, comment.FileMimeType)); } else { return(File(comment?.File, MediaTypeNames.Application.Octet, comment?.FileURL)); } } catch (InvalidOperationException) { return(File(comment?.File, MediaTypeNames.Application.Octet, comment?.FileURL)); } }
private ActionResult PrepareFileResult(IReport report, string ext, bool download, byte[] renderedBytes, ReportRegistry.Report reportInfo) { string fileDownloadName; var customFileName = report as ICustomFileName; if (customFileName != null) { fileDownloadName = customFileName.GetFileName(); } else { fileDownloadName = (reportInfo.Title ?? reportInfo.Key) + "_" + DateTime.Now.ToString("yyyyMMdd_HHss"); } fileDownloadName += "." + ext; if (download) { return(new FileContentResult(renderedBytes, "application/octet-stream") { FileDownloadName = fileDownloadName }); } var cd = new ContentDisposition { Inline = true, FileName = fileDownloadName }; Response.AddHeader("Content-Disposition", cd.ToString()); return(File(renderedBytes, UploadHelper.GetMimeType(fileDownloadName))); }
/// <summary> /// Executes the View for Export /// </summary> public ActionResult BeerXml(int recipeId) { var recipe = this.RecipeService.GetRecipeById(recipeId); if (recipe == null) { return(this.Issue404()); } var xmlString = this.BeerXmlExporter.Export(recipe); var xmlBytes = Encoding.Default.GetBytes(xmlString); var disposition = new ContentDisposition { // for example foo.bak FileName = string.Format("{0}-brewgr.xml", StringCleaner.CleanForUrl(recipe.RecipeName)), // always prompt the user for downloading, set to true if you want // the browser to try to show the file inline Inline = false, }; Response.AppendHeader("Content-Disposition", disposition.ToString()); return(new FileStreamResult(new MemoryStream(xmlBytes), "text/xml")); }
public async Task <ActionResult> LabReportCsv(string id) { var lab = await LabRepo.GetLabAndSettings(id); var teams = lab.DomAssignments; var res = new List <string> { "City,Date,Instructor,LabCode" }; res.Add(string.Format("{0},{1},{2},{3}", lab.City, lab.LabDate, lab.PrimaryInstructor, lab.LabCode)); res.Add(""); res.Add("Domain,TeamAuthKey"); res.AddRange(teams.Select(t => string.Format("{0},{1}", t.DomainName, t.TeamAuth))); var fileArray = Encoding.UTF8.GetBytes(string.Join(Environment.NewLine, res.ToArray())); var fileName = string.Format("Lab-{0}.csv", lab.LabName); string contentType = MimeMapping.GetMimeMapping(fileName); var cd = new ContentDisposition { FileName = fileName, Inline = false }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(fileArray, contentType)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } AcquiredItem = await _context.AcquiredItem .Include(r => r.ItemType).FirstOrDefaultAsync(m => m.ID == id); if (AcquiredItem == null) { return(NotFound()); } if (AcquiredItem.Attachment == null) { return(NotFound()); } ContentDisposition cd = new ContentDisposition { FileName = AcquiredItem.AttachmentFileName, Inline = true }; Response.Headers.Add("Content-Disposition", cd.ToString()); return(File(AcquiredItem.Attachment, AcquiredItem.AttachmentContentType)); }
public async Task <IActionResult> GetPdf([FromBody] GeneratePdfRequest request) { var article = await _articleService.FindOne(request.ArticleUrl, request.DeviceType, request.Inline); Stream stream; if (article != null && article.PdfDataSize != 0) { stream = new MemoryStream(article.PdfData); } else { stream = await _pdfService.ConvertUrlToPdf(request.ArticleUrl, request.DeviceType, request.Inline); await _articleService.CreateOrUpdate(request.ArticleUrl, request.DeviceType, request.Inline, stream); } var contentDisposition = new ContentDisposition { FileName = GetPdfFileName(request.ArticleUrl), DispositionType = request.Inline ? DispositionTypeNames.Inline : DispositionTypeNames.Attachment }; Response.Headers[HeaderNames.ContentDisposition] = contentDisposition.ToString(); stream.Position = 0; return(File(stream, "application/pdf")); }
public ActionResult LogotipoEmpresa(long id) { IEmpresasServicio srv = Servicios.EmpresasServicio(); Empresa empresa = srv.GetSingle(e => e.EmpresaID == id); if (empresa != null) { if (empresa.Logotipo == null) { return(File("~/Content/Images/Blanco.png", contentType: "image/png")); } else { var cd = new ContentDisposition { FileName = empresa.Logotipo.Nombre, Inline = false, }; Response.AppendHeader(name: "Content-Disposition", value: cd.ToString()); FileStream str = FileManager.ObtenerDocumento(empresa.Logotipo); return(new FileStreamResult(str, empresa.Logotipo.Mime)); } } else { return(HttpNotFound()); } }
public ActionResult BannerEmpresa(long id) { IEmpresasServicio srv = Servicios.EmpresasServicio(); Empresa empresa = srv.GetSingle(e => e.EmpresaID == id && e.Activo); FileStream str; string mime; string fileName; if (empresa == null || empresa.Banner == null) { return(File("~/Content/Images/Blanco.png", "image/png")); } else { str = FileManager.ObtenerDocumento(empresa.Banner); mime = empresa.Banner.Mime; fileName = empresa.Banner.Nombre; var cd = new ContentDisposition { FileName = fileName, Inline = false, }; Response.AppendHeader(name: "Content-Disposition", value: cd.ToString()); return(new FileStreamResult(str, mime)); } }
public ActionResult Miniatura(long id) { IComunicacionesServicio srv = Servicios.ComunicacionesServicio(); Comunicacion comunicacion = srv.GetSingle(c => c.ComunicacionID == id); if (comunicacion != null) { if (comunicacion.Imagen == null) { return(File("~/Content/Images/Blanco.png", contentType: "image/png")); } else { var cd = new ContentDisposition { FileName = Path.GetFileNameWithoutExtension(comunicacion.Imagen.Nombre) + "_thumb" + Path.GetExtension(comunicacion.Imagen.Nombre), Inline = false, }; Response.AppendHeader(name: "Content-Disposition", value: cd.ToString()); FileStream str = FileManager.ObtenerMiniatura(comunicacion.Imagen); return(new FileStreamResult(str, comunicacion.Imagen.Mime)); } } else { return(HttpNotFound()); } }
public ActionResult Logotipo(long?id = null) { IAplicacionesServicio srv = Servicios.AplicacionesServicio(); long appID = id ?? Aplicacion.AplicacionID; Aplicacion aplicacion = srv.GetSingle(c => c.AplicacionID == appID); if (aplicacion != null) { if (aplicacion.Logotipo == null) { return(File("~/Content/Images/PushNewsLogo.png", contentType: "image/png")); } else { var cd = new ContentDisposition { FileName = aplicacion.Logotipo.Nombre, Inline = false, }; Response.AppendHeader(name: "Content-Disposition", value: cd.ToString()); FileStream str = FileManager.ObtenerDocumento(aplicacion.Logotipo); return(new FileStreamResult(str, aplicacion.Logotipo.Mime)); } } else { return(HttpNotFound()); } }
public async Task <IActionResult> DownloadDocumentAsync(int documentId) { var file = await _appDbContext.Files.FirstOrDefaultAsync(k => k.Id == documentId); var fileDb = await _fileDbContext.FileDB.FirstOrDefaultAsync(k => k.Id == file.IdGuid); if (fileDb == null) { var minioResult = await DownloadProgramActivityVideoAsync(documentId); return(minioResult); } else { var result = await _fileService.DownloadDocumentAsync(documentId); if (result.FileView != null) { ContentDisposition cd = new ContentDisposition { FileName = result.FileView.Name, Inline = true // false = prompt the user for downloading; true = browser to try to show the file inline }; Response.Headers.Add("Content-Disposition", cd.ToString()); Response.Headers.Add("X-Content-Type-Options", "nosniff"); return(File(result.FileView.FileBytes, result.FileView.MimeType)); } return(Ok(result)); } }
public IActionResult DownloadCompareData(int year = 0) { if (year == 0) { year = ReportingYearsHelper.GetTheMostRecentCompletedReportingYear(); } var result = CompareEmployers(year) as ViewResult; var viewModel = result.Model as CompareViewModel; IEnumerable <CompareReportModel> data = viewModel?.CompareReports; //Ensure we some data if (data == null || !data.Any()) { return(new HttpNotFoundResult($"There is no employer data for year {year}")); } DataTable model = OrganisationBusinessLogic.GetCompareDatatable(data); //Setup the HTTP response var contentDisposition = new ContentDisposition { FileName = $"Compared GPG Data {ReportingYearsHelper.FormatYearAsReportingPeriod(year)}.csv", Inline = false }; HttpContext.SetResponseHeader("Content-Disposition", contentDisposition.ToString()); /* No Longer required as AspNetCore has response buffering on by default * Response.BufferOutput = true; */ //Track the download WebTracker.TrackPageView(this, contentDisposition.FileName); //Return the data return(Content(model.ToCSV(), "text/csv")); }
public static string GetHeaderValue(string fileName) { // If fileName contains any Unicode characters, encode according // to RFC 2231 (with clarifications from RFC 5987) foreach (char c in fileName) { if ((int)c > 127) { return(CreateRfc2231HeaderValue(fileName)); } } // Knowing there are no Unicode characters in this fileName, rely on // ContentDisposition.ToString() to encode properly. // In .Net 4.0, ContentDisposition.ToString() throws FormatException if // the file name contains Unicode characters. // In .Net 4.5, ContentDisposition.ToString() no longer throws FormatException // if it contains Unicode, and it will not encode Unicode as we require here. // The Unicode test above is identical to the 4.0 FormatException test, // allowing this helper to give the same results in 4.0 and 4.5. ContentDisposition disposition = new ContentDisposition() { FileName = fileName }; return(disposition.ToString()); }
public async Task <ActionResult> DownloadFile(SpecifyOptionsViewModel viewModel) { if (!await CheckOrganisationExists(viewModel.OrganisationID)) { return(RedirectToAction("SelectOrganisation")); } if (!ModelState.IsValid) { return(RedirectToAction("SpecifyOptions", new { viewModel.OrganisationID })); } TestFileSettings settings = new TestFileSettings( viewModel.OrganisationID, new Quarter(viewModel.ComplianceYear, viewModel.Quarter)); settings.NumberOfAatfs = viewModel.NumberOfAatfs; settings.NumberOfAes = viewModel.NumberOfAes; settings.AllProducers = viewModel.AllProducers; settings.NumberOfProduces = viewModel.NumberOfProducers; FileInfo xmlFile = await GenerateXml(settings); ContentDisposition cd = new ContentDisposition { FileName = xmlFile.FileName, Inline = false, }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(xmlFile.Data, "application/xml")); }
public async Task <ActionResult> ExportTenants(string id) { var lab = await LabRepo.GetLabAndSettings(id); var teams = lab.DomAssignments; var res = new List <string> { "Tenant,AdminUpn,TenantID,AssignedDNS" }; res.AddRange(teams.Select(t => t.AssignedTenantName + "," + t.TenantAdminUpn + "," + t.AssignedTenantId + "," + t.DomainName)); var city = lab.City.ToLower().Replace(" ", "").Replace(".", "").Replace("-", ""); city += (lab.LabDate.Month.ToString() + lab.LabDate.Day.ToString()); var fileArray = Encoding.UTF8.GetBytes(string.Join(Environment.NewLine, res.ToArray())); var fileName = string.Format("Lab-{0}.csv", city); string contentType = MimeMapping.GetMimeMapping(fileName); var cd = new ContentDisposition { FileName = fileName, Inline = false }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(fileArray, contentType)); }
public ActionResult ImportTaskLogs(string payerId) { if (string.IsNullOrEmpty(payerId)) { return(Content("Import task wasn't fired.")); } var tracerFileName = TransactionImportTracer.GetTracerFileName(payerId); if (!System.IO.File.Exists(tracerFileName)) { return(Content("Import task wasn't fired.")); } var file = new FileStream(tracerFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); if (file == null) { return(HttpNotFound()); } var contentDisposition = new ContentDisposition() { FileName = tracerFileName, Inline = true, }; Response.AddHeader("Refresh", "5"); Response.AppendHeader("Content-Disposition", contentDisposition.ToString()); return(File(file, "text/plain")); }
public static void AddContentDispositionHeader(string fileName, bool asAttachment) { string header = null; HttpRequest req = HttpContext.Current.Request; HttpResponse resp = HttpContext.Current.Response; if (req.Browser.Browser == "IE") { ContentDisposition cd = new ContentDisposition(); if (asAttachment == false) { cd.Inline = true; } cd.FileName = HttpUtility.UrlPathEncode(fileName); header = cd.ToString(); } else { string format = "filename=\"{0}\""; if (asAttachment) { format = "attachment; " + format; } header = string.Format(format, fileName); } resp.AddHeader("Content-Disposition", header); }
public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } var response = context.HttpContext.Response; response.ContentType = ContentType; var cd = new ContentDisposition { Inline = false, FileName = _fileDownloadName, DispositionType = "Inline", CreationDate = DateTime.Now }; response.AppendHeader("Content-Disposition", cd.ToString()); var checkAction = string.IsNullOrWhiteSpace(ViewName) ? context.RouteData.Values["action"].ToString() : ViewName; var pHtml = RenderRazorViewToString(checkAction, Model, context); var pdf = new PdfBytes { DocPageSize = _pageSize }; var pdfBytes = pdf.GetPdfBytesArray(pHtml); response.OutputStream.Write(pdfBytes, 0, pdfBytes.Length); }
protected override void WriteFile(HttpResponseBase response) { var cd = new ContentDisposition(); cd.FileName = _fileDownloadName; response.AddHeader("Content-Disposition", cd.ToString()); using (var zipStream = new ZipOutputStream(response.OutputStream)) { foreach (var file in _filesToZip) { var entry = new ZipEntry(Path.GetFileName(file)); zipStream.PutNextEntry(entry); using (var reader = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { byte[] buffer = new byte[ChunkSize]; int bytesRead; while ((bytesRead = reader.Read(buffer, 0, buffer.Length)) > 0) { byte[] actual = new byte[bytesRead]; Buffer.BlockCopy(buffer, 0, actual, 0, bytesRead); zipStream.Write(actual, 0, actual.Length); } } } } }
public static string GetHeaderValue(string fileName, bool inline = false, bool withoutBase = false) { // If fileName contains any Unicode characters, encode according // to RFC 2231 (with clarifications from RFC 5987) if (fileName.Any(c => (int)c > 127)) { var str = withoutBase ? "{0}; filename*=UTF-8''{2}" : "{0}; filename=\"{1}\"; filename*=UTF-8''{2}"; return(string.Format(str, inline ? "inline" : "attachment", fileName, CreateRfc2231HeaderValue(fileName))); } // Knowing there are no Unicode characters in this fileName, rely on // ContentDisposition.ToString() to encode properly. // In .Net 4.0, ContentDisposition.ToString() throws FormatException if // the file name contains Unicode characters. // In .Net 4.5, ContentDisposition.ToString() no longer throws FormatException // if it contains Unicode, and it will not encode Unicode as we require here. // The Unicode test above is identical to the 4.0 FormatException test, // allowing this helper to give the same results in 4.0 and 4.5. var disposition = new ContentDisposition { FileName = fileName, Inline = inline }; return(disposition.ToString()); }
public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentNullException("context"); } HttpResponseBase response = context.HttpContext.Response; response.ContentType = ContentType; if (!String.IsNullOrEmpty(FileDownloadName)) { // From RFC 2183, Sec. 2.3: // The sender may want to suggest a filename to be used if the entity is // detached and stored in a separate file. If the receiving MUA writes // the entity to a file, the suggested filename should be used as a // basis for the actual filename, where possible. ContentDisposition disposition = new ContentDisposition() { FileName = FileDownloadName }; string headerValue = disposition.ToString(); context.HttpContext.Response.AddHeader("Content-Disposition", headerValue); } WriteFile(response); }
public async Task <IActionResult> GenerateInvoice([Required][FromBody] GetInvoiceRequest request) { Invoice invoice; try { invoice = await _equipmentService.GenerateInvoice(request.Equipment); } catch (Exception e) { _logger.LogError(e, "Exception occured while generating invoice"); return(RedirectError("Exception occured while generating invoice. Please try again later")); } _logger.LogInformation($"Sending invoice: {JsonConvert.SerializeObject(invoice)}"); var stream = new MemoryStream(); await JsonSerializer.SerializeAsync(stream, invoice); var cd = new ContentDisposition { FileName = invoice.Title, Inline = true }; Response?.Headers?.Add("Content-Disposition", cd.ToString()); stream.Seek(0, 0); return(new FileStreamResult(stream, "application/octet-stream")); }
public async Task <IActionResult> GenerateDocument(string uxoid) { var contentType = "APPLICATION/octet-stream"; var uxo = await _uxoService.FetchUXO(uxoid); if (uxo == null) { return(NotFound(uxoid)); } var fileBytes = await _documentService.CreateDocument(uxo); if (fileBytes == null || fileBytes.Length == 0) { return(NoContent()); } var fileName = $"UXO-{DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mmZ")}.docx"; var contentDisposition = new ContentDisposition() { FileName = fileName, Inline = false }; Response.Headers.Add("Content-Disposition", contentDisposition.ToString()); return(File(fileBytes, contentType)); }
public ActionResult Download(string guid) { if (guid.IsNullOrWhiteSpace()) { Response.StatusCode = (int)HttpStatusCode.NotFound; var errorResponse = new { Success = "false", Message = "file not found" }; return(Json(errorResponse, JsonRequestBehavior.AllowGet)); } try { var jobGuid = Guid.Parse(guid); var job = _fpmUploadRepository.GetJob(jobGuid); var fileExt = Path.GetExtension(job.Filename); var filePath = Path.Combine(AppConfig.UploadFolder, jobGuid + fileExt); var fileData = System.IO.File.ReadAllBytes(filePath); var contentType = MimeMapping.GetMimeMapping(filePath); var cd = new ContentDisposition { FileName = job.Filename, Inline = true }; Response.AppendHeader("Content-Disposition", cd.ToString()); return(File(fileData, contentType)); } catch (Exception ex) { return(Redirect("/NotFound")); } }
public ActionResult DownloadDiagram(int id) { ActionResult actionResult = null; try { RetryableOperation.Invoke(ExceptionPolicies.General, () => { var diagram = _diagramService.GetByCustomerAndId(_appUserContext.Current.CurrentCustomer.Id, id); if (diagram != null) { var contentDisposition = new ContentDisposition { FileName = diagram.Filename, Inline = false, }; _contextManager.ResponseManager.AppendHeader("Content-Disposition", contentDisposition.ToString()); actionResult = new FileStreamResult(new MemoryStream(diagram.DiagramData), diagram.MimeType); } }); } catch (Exception ex) { _contextManager.ResponseManager.StatusCode = 500; _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message); } return(actionResult); }
public async Task <IActionResult> Download([FromQuery] string fileName) { var userIdString = User.Identity.Name; if (userIdString == null || !int.TryParse(userIdString, out int userId)) { return(BadRequest("Invalid token")); } var file = await _storage.RetrieveFileAsync(fileName, userIdString); if (file == null) { return(BadRequest("File does not exist")); } ContentDisposition contentDisposition = new ContentDisposition { FileName = fileName, //inline true tries to display the file in the browser Inline = false }; Response.Headers.Add("Content-Disposition", contentDisposition.ToString()); //exposes the content-disposition header to javascript code Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); return(File(file, FileContentType.Get(fileName)));; }
public IActionResult DownloadAttachment(string id) { Models.CommentModels.Comment comment = _context.Comment.SingleOrDefault(m => m.Id == id); try { if (comment.FileMimeType != null) { ContentDisposition cd = new ContentDisposition { FileName = comment.FileURL, Inline = true }; Response.Headers["Content-Disposition"] = cd.ToString(); return(File(comment.File, comment.FileMimeType)); } else { return(File(comment.File, MediaTypeNames.Application.Octet, comment.FileURL)); } } catch (InvalidOperationException) { return(File(comment.File, MediaTypeNames.Application.Octet, comment.FileURL)); } }
public async Task <ActionResult> ImagenSinEnlazar(long id) { IDocumentosServicio srv = Servicios.DocumentosServicio(); Documento imagen = srv.GetSingle(c => c.DocumentoID == id); if (imagen != null) { var cd = new ContentDisposition { FileName = imagen.Nombre, Inline = false, }; Response.Buffer = false; Response.Charset = "UTF-8"; Response.AppendHeader(name: "Content-Disposition", value: cd.ToString()); Response.AddHeader(name: "Content-Length", value: imagen.Tamano.ToString()); Response.ContentType = imagen.Mime; Response.Flush(); await FileManager.ObtenerDocumento(imagen, Response.OutputStream); return(new EmptyResult()); } else { return(HttpNotFound()); } }
public static void DefaultCtor_ExpectedDefaultPropertyValues() { var cd = new ContentDisposition(); Assert.Equal(DateTime.MinValue, cd.CreationDate); Assert.Equal("attachment", cd.DispositionType); Assert.Null(cd.FileName); Assert.False(cd.Inline); Assert.Equal(DateTime.MinValue, cd.ModificationDate); Assert.Empty(cd.Parameters); Assert.Equal(DateTime.MinValue, cd.ReadDate); Assert.Equal(-1, cd.Size); Assert.Equal("attachment", cd.ToString()); }
public void CultureSensitiveSetDateViaProperty_ShouldPersistToProprtyAndParametersCollectionAndRespectKindProperty() { CultureInfo origCulture = CultureInfo.CurrentCulture; try { CultureInfo.CurrentCulture = new CultureInfo("zh"); var cd = new ContentDisposition("inline"); var date = new DateTime(2011, 6, 8, 15, 34, 07, DateTimeKind.Unspecified); cd.CreationDate = date; Assert.Equal("Wed, 08 Jun 2011 15:34:07 -0000", cd.Parameters["creation-date"]); Assert.Equal(date, cd.CreationDate); Assert.Equal("inline; creation-date=\"Wed, 08 Jun 2011 15:34:07 -0000\"", cd.ToString()); } finally { CultureInfo.CurrentCulture = origCulture; } }
public void SetDateViaConstructor_ShouldPersistToPropertyAndPersistToParametersCollection() { string disposition = "inline; creation-date=\"" + ValidDateGmt + "\";"; string dispositionValue = "inline; creation-date=\"" + ValidDateGmtOffset + "\""; var cd = new ContentDisposition(disposition); Assert.Equal(ValidDateGmtOffset, cd.Parameters["creation-date"]); Assert.Equal(new DateTime(2009, 5, 17, 15, 34, 07, DateTimeKind.Local) + s_localTimeOffset, cd.CreationDate); Assert.Equal("inline", cd.DispositionType); Assert.Equal(dispositionValue, cd.ToString()); }