MVC4, C#.NET 4.5: requirement : download text file to local system on the click of the button when passing very long string to the controller action. Below works fine, but truncates very long string, so not all data get to controller. How to overcome this limitation? Many thanks
VIEW
$("#myBtn").click(function () {
var myId = 123;
var myValues = “1,A,1/01/2014;2,B,2/02/2014; ……. ”; // string of about 10K characters
var actionUrl = '@Html.Raw(@Url.Action("DownloadMyFile", "Home", new { parm1 = "PLACEHOLDER1", parm2 = "PLACEHOLDER2" }))';
var url1 = actionUrl.replace('PLACEHOLDER1', myId);
var url2 = url1.replace('PLACEHOLDER2', myValues);
window.location = url2;
});
CONTROLLER
public FileResult DownloadMyFile ((int parm1 = 0, string parm2 = null)
{
// HERE parm2 HAS ONLY 5237 CHARACTERS OUT OF VERY LONG STRING
//…… processing code here
return File(_fileBytes, "text", "MyFile.txt"); // Download to local system,
}