Upload Safety

When you upload a file, your data is not saved on the server. Your file is read and data is displayed in the template area. See the actual code used below when uploading the file .

    
        [HttpPost]
        public ActionResult Index(HttpPostedFileBase file)
        {
            var text = string.Empty;
            StringBuilder sb = new StringBuilder();
            if (file.ContentLength > 0)
            {
                Stream theStream = file.InputStream;
                using (StreamReader sr = new StreamReader(theStream))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        sb.AppendLine(line);
                    }
                }
            }
            ViewBag.Template = sb.ToString();
            return View();
        }