Click here to Skip to main content
15,896,118 members
Articles / Web Development / ASP.NET

Cross Domain/Platform Authentication and Data Transfer

Rate me:
Please Sign up or sign in to vote.
4.87/5 (10 votes)
29 Dec 2008CPOL14 min read 90.3K   917   66  
Introduces a methodology for authenticating user in cross domain/platform and transferring user data from one site to another during the authentication process.
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)


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

Comments and Discussions