Compartilhar via


Flexible-Layout Cobranding (Branching Example)

Flexible-Layout Cobranding (Branching Example)

The request that comes to your cobranding template file potentially contains information on the query string, depending on variables sent to the original LoginUser, LogoTag2, or AuthURL2 method call that brought the connecting user to the Login server.

The following example code shows how to implement multiple cobranding templates from a single source file, and how to display different templates based on site-specific logic by using the query string parameters passed to your cobranding script. You can offer multiple language options for your site (such as German or English) based on the language ID (lid), and you can perform switching based on the .NET Passport-provided PP_PAGE and PP_SERVICE variables or custom variables provided by your site. To retrieve any of the cobranding query string parameters in Active Server Pages (ASP), use the Request.Querystring method.

<%
Response.Buffer=True
Response.ContentType = "application/x-javascript" '// set the content-type correctly
dim lid, msg, area, SProtocol, PP_SERVICE
if Request.ServerVariables("HTTPS") = "on" then 
'// any content called by template should use same protocol as template itself
  sProtocol = "https://"
Else
  sProtocol = "https://"
End If  

If Request.QueryString <> "" Then
   lid = Request.Querystring("lid")
   area=Request.QueryString("area")
   PP_SERVICE = Request.QueryString("PP_SERVICE")
   Select Case PP_SERVICE
      Case "login" '// this is flexible-layout cobranding
%>
      CBLoginBody = "<BLOCKQUOTE><H1>My Site presents Microsoft .NET Passport Sign-in</H1>";
      CBLoginBody += "<P>The section below is the actual sign-in interface for .NET Passport. ";
      CBLoginBody += "See <A HREF="https://www.passport.com" TARGET="_new">the .NET Passport site</A> ";
      CBLoginBody += " for more information about .NET Passport.";
      CBLoginBody += "<P>PASSPORT_UI"; '//the token
      <%If area="VIP" Then%>
      CBLoginBody += "<P>Thanks for using the VIP area of My Site!";
      <%Else%>
      CBLoginBody += "<P>Thanks for using My Site and .NET Passport!";
      <%End If%>
      CBLoginBody += "</BLOCKQUOTE>";	
   <% Case "registration" '// this is flexible-layout cobranding %>
      CBRegistrationBody = "<BLOCKQUOTE><H1>My Site presents .NET Passport Registration</H1>";
      CBRegistrationBody += "<P>The section below is the actual registration interface for .NET Passport. ";
      CBRegistrationBody += "See <A HREF='https://www.passport.com' TARGET='_new'> the .NET Passport site</A> ";
      CBRegistrationBody += "for more information about .NET Passport. ";
      CBRegistrationBody += "<P>PASSPORT_UI"; '//the token
      CBRegistrationBody += "<P>You will need to register for a .NET Passport in order to continue viewing My Site. ";
      CBRegistrationBody += "</BLOCKQUOTE>";

   <% End Select

End If
Response.End
%>

Notes

The following notes pertain to the preceding example and to cobranding in general.

  • Some browser issues can affect cobranding. Certain browsers, for example, cannot properly decode the query string parameters on arrival at the Login server. In order to deal with cobranding for users of those browsers, you may need to write code that parses the unescaped query string to extract your variables from the query string in the cobranding template. Also note the Response.Buffer = True and Response.End method calls in the preceding ASP example. These calls are included specifically to prevent a known issue with Netscape browsers, which can occasionally time out when attempting to download dynamic content without a fixed file size. Turning buffering on for the Microsoft® Internet Information Services (IIS) server, either on a per-file basis (for ASP cobranding templates only) or site-wide, prevents this problem. Non-ASP implementations that generate dynamic content may need to use similar platform- or server-specific methods for buffering content or declaring file size to avoid this problem. Static cobranding files will not experience this problem.

  • Code in this example checks to see whether the cobranding template itself is being called from an SSL-protected network page by checking whether Request.ServerVariables("HTTPS") = "ON". This allows the cobranding to return SSL-protected images to SSL-protected pages and non-SSL images to non-SSL pages and avoid mixed-content warnings for the end user.

  • If cobranding template variables are not provided in the template, Microsoft .NET Passport network defaults will be used for everything but the image, which will attempt to default to the image indicated by CoBrandImageURL.

  • CoBrandURL + "?" must always return a valid template. In other words, there should always be an established default for the five required JavaScript variables assuming no query string at all. This is to protect against the case in which the coBrandArgs get truncated by the browser as sent in the query string.

  • Set the content type in the response header to "application/x-javascript". In ASP, do this using the Response.ContentType method.

See Also

Manager.LogoTag2 | Manager.AuthURL2