Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The length of the query string for this request exceeds the configured maxQueryStringLength value

I am trying to redirect to a view and keep getting the error posted in the question title.

During breakpoint testing the code passing though the first bit of code iv lay down below setting the message and setting the exception. after continuing after the return redirect the very next page displayed is as follows.

enter image description here

Adding break points to the ErrorController and error model i found that the code never gets there.

The view i'm trying to post to is an error page. Here is so code to help you see the problem.

The RedirectToAction:

string message;
message = "An error has occured during the communication to lightstone, this is likely a timeout issue and could be the result of a bad connection. Please go back and try again.";
return RedirectToAction("Error", "Error", new { ex = ex.ToString(), message =  message});

The action in my ErrorController:

public ActionResult Error(string ex, string message)
{
   ViewBag.Message = "Error";
   return View(new ErrorModel(ex, message));
}

My Error model:

namespace MvcResComm.Models
{
    public class ErrorModel
    {
        public string ex { get; set; }
        public string message { get; set; }

        public ErrorModel(string ex, string message)
        {
            this.ex = ex;
            this.message = message;
        }
    }
}
like image 803
Pomster Avatar asked Jul 11 '13 10:07

Pomster


1 Answers

In the root web.config for your project, under the system.web node:

<system.web>
    <httpRuntime maxUrlLength="10999" maxQueryStringLength="2097151" />
...

In addition, I had to add this under the system.webServer node or I got a security error for my long query strings:

<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxUrl="10999" maxQueryString="9999" />
      </requestFiltering>
    </security>
...
like image 149
theJerm Avatar answered Oct 02 '22 20:10

theJerm