2011-02-02 19 views
9

Por alguna razón estoy recibiendo un error tratando de volverASP.NET MVC3 HttpStatusCodeResult statusDescription - Argumento especificado está fuera del rango de valores válidos

new HttpStatusCodeResult(500, statusDescription);

En mi aplicación MVC3. Se explota con el error

Specified argument was out of the range of valid values. 
Parameter name: value 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. 
Parameter name: value 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values. 
Parameter name: value] 
    System.Web.HttpResponse.set_StatusDescription(String value) +4877926 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +785441 
    System.Web.Mvc.Controller.ExecuteCore() +159 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335 
    System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62 
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20 
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.372 

Si cambio mi resultado para volver new HttpStatusCodeResult(500, "statusDescription");

A continuación, trabajar bien, ¿hay algún tipo de restricción de longitud en estado Descripción?

Respuesta

22

En cuanto a la fuente, or at the documentation, no puede tener más de 512 caracteres.

+4

Volviendo a esta respuesta años más tarde, todavía me enoja lo estúpido que es este error. Incluso si tienen que hacerlo, el hecho de que no fue un mensaje de error significativo y junto con él no falla rápidamente por establecer un valor demasiado largo. I_ಠ –

+1

Solo tuve que pasar por toda la WebAPI y encontrar lugares donde se establecía ReasonPhrase y asegurarme de que la longitud era inferior a 512. Después de semanas de personas que desconcertaban mensajes de error ambiguos en los registros. – Beans

Cuestiones relacionadas