Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net mvc serving txt gets truncated
    primarykey
    data
    text
    <p>I'm trying to serve a txt file made from the database using an action. The action is the following:</p> <pre><code>public ActionResult ATxt() { var articulos = _articulosService.ObteTotsArticles(); return File(CatalegATxt.ATxt(articulos), "text/plain"); } </code></pre> <p>and the CatalegATxt class is:</p> <pre><code>using System; using System.Collections.Generic; using System.IO; using System.Text; using WebDibaelsaMVC.DTOs.Busqueda; namespace WebDibaelsaMVC.TxtLib { public static class CatalegATxt { public static Stream ATxt(IEnumerable&lt;ArticuloBusquedaDTO&gt; articles) { var stream = new MemoryStream(); var streamWriter = new StreamWriter(stream, Encoding.UTF8); foreach (ArticuloBusquedaDTO article in articles) { streamWriter.WriteLine(article.ToStringFix()); } stream.Seek(0, SeekOrigin.Begin); return stream; } public static string ToStringFix(this ArticuloBusquedaDTO article) { string result = ""; result += article.CodigoArticulo.PadRight(10, ' ').Substring(0, 10); result += article.EAN.Trim().PadLeft(13, '0').Substring(0, 13); result += article.NombreArticulo.PadRight(100, ' ').Substring(0, 100); result += article.Marca.PadRight(100, ' ').Substring(0, 100); result += article.Familia.PadRight(50, ' ').Substring(0, 50); result += article.PrecioCesion.ToStringFix(); result += article.PVP.ToStringFix(); return result; } private static string ToStringFix(this double numero) { var num = (int)Math.Round(numero * 100, 0); string result = num.ToString().PadLeft(10, '0'); return result; } } } </code></pre> <p>it just writes the file lines based on the stuff I got from the database. But when I look at the file it looks truncated. The file is about 8Mb. I also tried converting to <code>byte[]</code> before returning from ATxt with the same result.</p> <p>Any idea?</p> <p>Thanks,</p> <p>Carles</p> <p><strong>Update:</strong> I also tried to serve XML from the same content and it also gets truncated. It doesn't get truncated on the data (I thought it might have been an EOF character in it) but it truncates in the middle of a label...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload