protected void SubmitVideo_ServerClick(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.Title.Text) == false && String.IsNullOrEmpty(this.Description.Text) == false && String.IsNullOrEmpty(this.Category.SelectedValue) == false && String.IsNullOrEmpty(this.Keyword.Text) == false) { GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(ServiceNames.YouTube, "TesterApp"); YouTubeService service = new YouTubeService(authFactory.ApplicationName, "ytapi-FrankMantek-TestaccountforGD-sjgv537n-0", "AI39si4v3E6oIYiI60ndCNDqnPP5lCqO28DSvvDPnQt-Mqia5uPz2e4E-gMSBVwHXwyn_LF1tWox4LyM-0YQd2o4i_3GcXxa2Q" ); authFactory.Token = HttpContext.Current.Session["token"] as string; service.RequestFactory = authFactory; try { YouTubeEntry entry = new YouTubeEntry(); entry.Media = new Google.GData.YouTube.MediaGroup(); entry.Media.Description = new MediaDescription(this.Description.Text); entry.Media.Title = new MediaTitle(this.Title.Text); entry.Media.Keywords = new MediaKeywords(this.Keyword.Text); // entry.Media.Categories MediaCategory category = new MediaCategory(this.Category.SelectedValue); category.Attributes["scheme"] = YouTubeService.DefaultCategory; entry.Media.Categories.Add(category); FormUploadToken token = service.FormUpload(entry); HttpContext.Current.Session["form_upload_url"] = token.Url; HttpContext.Current.Session["form_upload_token"] = token.Token; string page = "http://" + Request.ServerVariables["SERVER_NAME"]; if (Request.ServerVariables["SERVER_PORT"] != "80") { page += ":" + Request.ServerVariables["SERVER_PORT"]; } page += Request.ServerVariables["URL"]; HttpContext.Current.Session["form_upload_redirect"] = page; Response.Redirect("UploadVideo.aspx"); } catch (GDataRequestException gdre) { HttpWebResponse response = (HttpWebResponse)gdre.Response; } } }