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.
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;
}
}
}
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>
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With