Server Error in '/' Application.

Length cannot be less than zero.
Parameter name: length

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: Length cannot be less than zero.
Parameter name: length

Source Error:


Line 196:    {
Line 197:        string _tipoContratto = categoria.Substring(categoria.LastIndexOf(' ') + 1, categoria.Length - categoria.LastIndexOf(' ') - 1).Substring(0, 2).ToUpper();
Line 198:        string _categoria = categoria.Substring(0, categoria.LastIndexOf(' '));
Line 199:
Line 200:        return string.Format("<root><categoria>{0}</categoria><tipoContratto>{1}</tipoContratto></root>", _categoria, _tipoContratto);

Source File: d:\inetpub\webs\dorjeit\App_Code\ProxyWS.cs    Line: 198

Stack Trace:


[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
   System.String.Substring(Int32 startIndex, Int32 length) +13148884
   ProxyWS.SplitCategoria(String categoria) in d:\inetpub\webs\dorjeit\App_Code\ProxyWS.cs:198
   ProxyWS.Get_Lista_Area_Full(String tipoTabella, String categoriaComposta, String idComune, String area, String tipologia, String prezzoMin, String prezzoMax, String superficieMin, String superficieMax, String locali, Int32 take, String opzioniWeb) in d:\inetpub\webs\dorjeit\App_Code\ProxyWS.cs:354
   selezione_immobili_map.AvviaRicerca(String tipoTabella, String categoria, String comune, String area, String tipologie, String prezzoMin, String prezzoMax, String superficieMin, String superficieMax, String locali, String listType, String jolly1) in d:\inetpub\webs\dorjeit\re\selezione-immobili-map.aspx.cs:428
   selezione_immobili_map.AvviaRicerca(String tipoTabella, String categoria, String comune, String area, String tipologie, String prezzoMin, String prezzoMax, String superficieMin, String superficieMax, String locali, String listType) in d:\inetpub\webs\dorjeit\re\selezione-immobili-map.aspx.cs:410
   selezione_immobili_map.Page_Load(Object sender, EventArgs e) in d:\inetpub\webs\dorjeit\re\selezione-immobili-map.aspx.cs:250
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +52
   System.Web.UI.Control.OnLoad(EventArgs e) +97
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +693


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