Server Error in '/' Application.

Index was outside the bounds of the array.

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.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:


Line 44:         else if (YoutubeUrl.IndexOf('/') < 6)
Line 45:         {
Line 46:             youTubeThumb = YoutubeUrl.Split('/')[3];
Line 47:         }
Line 48:         else if (YoutubeUrl.IndexOf('/') > 6)

Source File: c:\website\bcahapur.edu.in\VideoGallery.aspx.cs    Line: 46

Stack Trace:


[IndexOutOfRangeException: Index was outside the bounds of the array.]
   VideoGallery.getYouTubeThumbnail(String YoutubeUrl) in c:\website\bcahapur.edu.in\VideoGallery.aspx.cs:46
   VideoGallery.GridView1_RowDataBound(Object sender, GridViewRowEventArgs e) in c:\website\bcahapur.edu.in\VideoGallery.aspx.cs:69
   System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) +137
   System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +262
   System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +5059
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +97
   System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +18
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +165
   VideoGallery.BindGrid() in c:\website\bcahapur.edu.in\VideoGallery.aspx.cs:24
   VideoGallery.Page_Load(Object sender, EventArgs e) in c:\website\bcahapur.edu.in\VideoGallery.aspx.cs:17
   System.Web.UI.Control.OnLoad(EventArgs e) +106
   System.Web.UI.Control.LoadRecursive() +68
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785


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