This question already has an answer here:

I'm getting the "request url too long" error whenever I click on my actionlink. It makes sense since this is a really long string, but I need to pass this string to the controller somehow.

Here's the actionlink from the View:

@Html.ActionLink("Download Error Text File", "GenerateFile", "Home", new { @errorMessage = Model.customersError }, new { @id = "downloadfile" })

It is calling this action result in the controller:

public ActionResult GenerateFile(string errorMessage)
            var byteArray = Encoding.ASCII.GetBytes(errorMessage);
            var stream = new MemoryStream(byteArray);

            return File(stream, "text/plain", "Customer_Errors-" + DateTime.Now.Date.ToString("MM-dd-yyyy") + ".txt");

So this is a link the user would click to download a plain text file with all the errors. Is there an alternative way of passing this value to the controller so it doesn't get put in the url?

Related posts

Recent Viewed