![](/img/trans.png)
[英]How to save in asp.net mvc multiple input boxes text in one record
[英]How to save multiple values into one text file in ASP.NET MVC
我需要将多个文本框中的多个值保存到一个文本文件中。 我只能保存firstName
而不能保存Surname
。 关于如何将姓氏和名字保存到一个文本文件中的任何建议?
这是我的控制器:
public class SampleController : Controller
{
//
// GET: /Sample/
[HttpPost]
public ActionResult Create(Information information)
{
var byteArray = Encoding.ASCII.GetBytes(information.FirstName);
var stream = new MemoryStream(byteArray);
return File(stream, "text/plain", "your_file_name.txt");
}
[HttpGet]
public ActionResult Create()
{
return View();
}
}
public class SampleController : Controller
{
//
// GET: /Sample/
[HttpPost]
public ActionResult Create(Information information)
{
var byteArray = Encoding.ASCII.GetBytes(information.FirstName + ";" + information.SureName);
var stream = new MemoryStream(byteArray);
return File(stream, "text/plain", "your_file_name.txt");
}
[HttpGet]
public ActionResult Create()
{
return View();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.