User-1679949502 posted
Hello, I have a problem. I'm working in this really old project from 2013... and I'm going crazy with this.
I don't have controllers or models and I'm trying to create an .CSV file so the user can use it as a template, then upload it!
I'm using this to create the template:
@{
Layout = null;
WebSecurity.RequireAuthenticatedUser();
Response.Clear();
var filename = String.Format("createorder.csv");
Response.AddHeader("Content-disposition", "attachment; filename=" + filename);
Response.ContentType = "application/octet-stream";
int i = 0;
}
@if (i == 0)
{
@:"@Html.Raw("User Id")","@Html.Raw("Name")","@Html.Raw("Address Type")","@Html.Raw("Address")","@Html.Raw("Address 2")","@Html.Raw("City")","@Html.Raw("State")","@Html.Raw("Zip")", "@Html.Raw("Country")", "@Html.Raw("Phone")","@Html.Raw("Item Id")","@Html.Raw("Item
Quantity")"
}
And it's working but this creates the headers in the 3rd row, leaving the 2 first rows empty. Then when the user upload the file I'm starting reading from the 4th row,,, and I was wondering if there is a way to create the headers in the first row.
Or a way to download a file(withoud creating it) using razor syntax. :(