Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Cross Domain/Platform Authentication and Data Transfer

, 29 Dec 2008
Introduces a methodology for authenticating user in cross domain/platform and transferring user data from one site to another during the authentication process.
CrossSiteAuthentication.zip
CrossSiteAuthentication
AuthenticationSite
App_Code
App_Data
CustomerDB.mdf
CustomerDB_Log.LDF
Bin
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll.refresh
Microsoft.Practices.ObjectBuilder.dll
images
line.JPG
Site1.JPG
Site2.JPG
ThirdPartySite
App_Code
App_WebReferences
AuthenticationService
AuthenticationService.disco
AuthenticationService.discomap
AuthenticationService.wsdl
images
line.JPG
Site1.JPG
Site2.JPG
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class AuthMaster : System.Web.UI.MasterPage
{
    public string TableWidth = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        //default to SiteID="1"
        string SiteID = Request.QueryString["SiteID"] == null ? "1" : Request.QueryString["SiteID"].ToString();

        SiteInfo MySiteInfo = new SiteInfo();
        //use Session["SiteInfo"] to reduce database traffic. 
        //This is userful since many pages at the web site uses the same master page.
        try
        {
            if (Session["SiteInfo"] == null)
            {
                MySiteInfo.SiteID = int.Parse(SiteID);
                MySiteInfo.RetrieveSiteInfo();
                Session["SiteInfo"] = MySiteInfo;
            }
            else
            {
                MySiteInfo = (SiteInfo)Session["SiteInfo"];
                //check to see if SiteID in session is the same as the current. If changed, retrieve new site info
                if (MySiteInfo.SiteID != int.Parse(SiteID))
                {
                    MySiteInfo.SiteID = int.Parse(SiteID);
                    MySiteInfo.RetrieveSiteInfo();
                    Session["SiteInfo"] = MySiteInfo;
                }
            }

            ApplySiteStyle(MySiteInfo);
        }
        catch (Exception ex)
        {
            lblMasterPageError.Text=ex.Message.ToString();
        }
    }

    private void ApplySiteStyle(SiteInfo siteInfo)
    {
        MainStyle.Href = siteInfo.StyleSheetName;
        imgHeader.ImageUrl = siteInfo.HeaderImagePath;
        imgHeader.Width = Unit.Pixel((int)siteInfo.HeaderWidth);
        imgHeader.Height = Unit.Pixel((int)siteInfo.HeaderHeight);
        lblHeaderText.Text = siteInfo.HeaderText;
        TableWidth = (imgHeader.Width == 0 ? "800" : imgHeader.Width.ToString());
        DataBind();
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Tomz_KV
Web Developer
United States United States
Web & Database Developer. Design and implement web and database applications utilizing Microsoft and other development tools.

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 29 Dec 2008
Article Copyright 2008 by Tomz_KV
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid