Đrakenus
Đrakenus

Reputation: 540

pass huge string to c# controller via js

I have MVC view page where i have text area and input box and javascript function assigned to button like this

function Process() {
    var input = $("#PrologUserInputTextArea").val();
    var query = $("#PrologQueryTextArea").val();

    $.get("@Url.Action("Process")", { userInput: input, query: query }, function (data) {
        cleanDiv();
        $("#PrologResultTextArea").val(data);
        //do some work with 
    });
}

and in mvc controller i have method just like this :

public async Task<string> Process(string userInput, string query)
{
    try
    {
        return await Proc.Process(userInput, query);
    }
    catch (PrologException e)
    {
        return e.Message;
    }
}

This works as it should when I write small amount of text in text area (about 50 lines) but when I try several hundreds of lines this wont pass the string to controller. Is there some check in javascript where this function won't pass the string? How can I pass enormous string to controller?

Upvotes: 0

Views: 199

Answers (1)

Dario Griffo
Dario Griffo

Reputation: 4274

Your problem is related to the size, you should make a post instead of a get

Check this out

https://www.google.com/?q=http%20query%20string%20limit#q=http+query+string+limit

Upvotes: 2

Related Questions