Click here to Skip to main content
15,896,063 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.Data.SqlClient;
using System.Configuration;
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 Microsoft.Practices.EnterpriseLibrary.Data;

/// <summary>
/// Summary description for SiteInfo
/// </summary>
public class SiteInfo
{
    int _siteID=-1;
    string _dataTransferProcNameName;
    string _headerImagePath;
    int _headerHeight;
    int _headerWidth;
    string _headerText;
    string _styleSheetName;
    int _daysToRemember;
    string _webServiceKey;
    string _returnUrl;

    public SiteInfo()
    {
    }
    public int SiteID
    {
        get { return _siteID; }
        set { _siteID = value; }
    }
    public string DataTransferProcName
    {
        get { return _dataTransferProcNameName; }
    }
    public string HeaderImagePath
    {
        get { return _headerImagePath; }
    }
    public int HeaderHeight
    {
        get { return _headerHeight; }
    }
    public int HeaderWidth
    {
        get { return _headerWidth; }
    }
    public string HeaderText
    {
        get { return _headerText; }
    }
    public string StyleSheetName
    {
        get { return _styleSheetName; }
    }
    public int DaysToRemember
    {
        get { return _daysToRemember; }
    }
    public string WebServiceKey
    {
        get { return _webServiceKey; }
    }
    public string ReturnUrl
    {
        get { return _returnUrl; }
        set { _returnUrl = value; }
    }

    public void RetrieveSiteInfo()
    {
        if (_siteID == -1)
            throw new Exception("SiteID is missing");

        SqlDataReader rd = null;
        try
        {
            Database db = DatabaseFactory.CreateDatabase();
            rd = (SqlDataReader) db.ExecuteReader("SiteInfo_GetSiteInfo", new object[] { _siteID });

            if (rd.Read())
            {
                _dataTransferProcNameName = rd["DataTransferProcName"].ToString();
                _headerImagePath = rd["HeaderImagePath"].ToString();
                _headerHeight = Convert.ToInt16((rd["HeaderHeight"] == DBNull.Value ? -1 : rd["HeaderHeight"]));
                _headerWidth = Convert.ToInt16((rd["HeaderWidth"] == DBNull.Value ? -1 : rd["HeaderWidth"]));
                _styleSheetName = rd["StyleSheetName"].ToString();
                _daysToRemember = Convert.ToInt16(rd["DaysToRemember"] == DBNull.Value ? 0 : rd["DaysToRemember"]);
                _webServiceKey = rd["WebServiceKey"].ToString();
            }
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            if (rd != null)
                rd.Close();
        }
    }
}

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