protected void Page_Init(object sender, EventArgs e) { AuthenticationMode eAuthenticationMode = AuthenticationMode.None; string strSid = ""; AuthenticationSection objAuthenticationSection = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; if ( objAuthenticationSection != null ) { eAuthenticationMode = objAuthenticationSection.Mode; } if ( eAuthenticationMode == AuthenticationMode.Forms ) { if ( HttpContext.Current.User.Identity.IsAuthenticated == false ) { Uri baseUrl = new Uri(Request.Url, Request.FilePath + "/.."); Response.Redirect(baseUrl.ToString() + "default.aspx?ReturnUrl=../WebFeed.aspx"); } TSFormAuthTicketInfo objTSFormAuthTicketInfo = new TSFormAuthTicketInfo(HttpContext.Current); strSid = objTSFormAuthTicketInfo.UserSid; // // TODO: Need to correctly call this // //Response.Write("\nshowWorkspaceNotification();"); } HttpContext.Current.Response.AppendHeader("Vary", "Accept"); FeedXmlVersion xmlVersion; string contentType; ContentNegotiationHelper.GetPreferredXmlVersion(out xmlVersion, out contentType); // downlevel requests cannot specify a folder if (xmlVersion == FeedXmlVersion.Win7 && Request.PathInfo.Length != 0) { Response.StatusCode = 404; Response.End(); } HttpContext.Current.Response.ContentType = contentType; string rdpRenderMode = HttpContext.Current.Request.Params.Get("rdpRender"); bool rdpEmbed = !String.IsNullOrEmpty(rdpRenderMode) && rdpRenderMode.Trim().ToLower(CultureInfo.InvariantCulture).Equals("inline"); try { WebFeed tswf = new WebFeed(rdpEmbed ? RdpType.Both : RdpType.Link); oXML = tswf.GenerateFeed(strSid, xmlVersion, Request.PathInfo, true); } catch (WorkspaceUnknownFolderException) { Response.StatusCode = 404; Response.End(); } catch (WorkspaceUnavailableException wue) { // This exception is raised when we cannot contact the appropriate sources to obtain the workspace information. // This is an edge case that can ocurr e.g. if the cpub server we're pointing to is down. Response.StatusCode = 503; // Write a simple text error string to the body, so that if an administrator happens to be accessing the feed via a browser, we can point them in the right direction // We need to wrap this in some sort of tags, otherwise IE does not display the message (since it expects an XML content-type) Response.Write("<Error>" + wue.Message + "</Error>"); Response.End(); } }
protected void Page_Init(object sender, EventArgs e) { AuthenticationMode eAuthenticationMode = AuthenticationMode.None; string strSid = ""; AuthenticationSection objAuthenticationSection = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; if (objAuthenticationSection != null) { eAuthenticationMode = objAuthenticationSection.Mode; } if (eAuthenticationMode == AuthenticationMode.Forms) { if (HttpContext.Current.User.Identity.IsAuthenticated == false) { Uri baseUrl = new Uri(Request.Url, Request.FilePath + "/.."); Response.Redirect(baseUrl.ToString() + "default.aspx?ReturnUrl=../WebFeed.aspx"); } TSFormAuthTicketInfo objTSFormAuthTicketInfo = new TSFormAuthTicketInfo(HttpContext.Current); strSid = objTSFormAuthTicketInfo.UserSid; // // TODO: Need to correctly call this // //Response.Write("\nshowWorkspaceNotification();"); } HttpContext.Current.Response.AppendHeader("Vary", "Accept"); FeedXmlVersion xmlVersion; string contentType; ContentNegotiationHelper.GetPreferredXmlVersion(out xmlVersion, out contentType); // downlevel requests cannot specify a folder if (xmlVersion == FeedXmlVersion.Win7 && Request.PathInfo.Length != 0) { Response.StatusCode = 404; Response.End(); } HttpContext.Current.Response.ContentType = contentType; string rdpRenderMode = HttpContext.Current.Request.Params.Get("rdpRender"); bool rdpEmbed = !String.IsNullOrEmpty(rdpRenderMode) && rdpRenderMode.Trim().ToLower(CultureInfo.InvariantCulture).Equals("inline"); try { WebFeed tswf = new WebFeed(rdpEmbed ? RdpType.Both : RdpType.Link); oXML = tswf.GenerateFeed(strSid, xmlVersion, Request.PathInfo, true); } catch (WorkspaceUnknownFolderException) { Response.StatusCode = 404; Response.End(); } catch (WorkspaceUnavailableException wue) { // This exception is raised when we cannot contact the appropriate sources to obtain the workspace information. // This is an edge case that can ocurr e.g. if the cpub server we're pointing to is down. Response.StatusCode = 503; // Write a simple text error string to the body, so that if an administrator happens to be accessing the feed via a browser, we can point them in the right direction // We need to wrap this in some sort of tags, otherwise IE does not display the message (since it expects an XML content-type) Response.Write("<Error>" + wue.Message + "</Error>"); Response.End(); } }