/// <summary> /// Adds attributes to an HTML <A> tag that will be written by the caller using /// <see cref="HtmlTextWriter.RenderBeginTag(HtmlTextWriterTag)" /> after this method. /// </summary> /// <param name="writer">The HTML writer.</param> /// <param name="response">The response.</param> /// <param name="windowStatus">The text to try to display in the status bar on mouse hover.</param> protected void RenderOpenIdMessageTransmissionAsAnchorAttributes(HtmlTextWriter writer, HttpResponseMessage response, string windowStatus) { Requires.NotNull(writer, "writer"); Requires.NotNull(response, "response"); // We render a standard HREF attribute for non-javascript browsers. writer.AddAttribute(HtmlTextWriterAttribute.Href, response.GetDirectUriRequest().AbsoluteUri); // And for the Javascript ones we do the extra work to use form POST where necessary. writer.AddAttribute(HtmlTextWriterAttribute.Onclick, this.CreateGetOrPostAHrefValue(response) + " return false;"); writer.AddStyleAttribute(HtmlTextWriterStyle.Cursor, "pointer"); if (!string.IsNullOrEmpty(windowStatus)) { writer.AddAttribute("onMouseOver", "window.status = " + MessagingUtilities.GetSafeJavascriptValue(windowStatus)); writer.AddAttribute("onMouseOut", "window.status = null"); } }
/// <summary> /// Gets the javascript to executee to redirect or POST an OpenID message to a remote party. /// </summary> /// <param name="requestRedirectingResponse">The request redirecting response.</param> /// <returns> /// The javascript that should execute. /// </returns> private string CreateGetOrPostAHrefValue(HttpResponseMessage requestRedirectingResponse) { Requires.NotNull(requestRedirectingResponse, "requestRedirectingResponse"); Uri directUri = requestRedirectingResponse.GetDirectUriRequest(); return "window.dnoa_internal.GetOrPost(" + MessagingUtilities.GetSafeJavascriptValue(directUri.AbsoluteUri) + ");"; }