Default.aspx.cs

 

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.Security;

using UMEDIASERVERLib;

 

namespace USessionAuth

{

    public partial class _Default : System.Web.UI.Page

    {

        public string m_sSecureTokenForHTML5 = "";

        public string m_sSecureTokenForHTML5File = "";

 

        protected void Page_Load(object sender, EventArgs e)

        {

            bool bSameComputerOrDomain = true; //Media Server and Web Server run on the same computer or domain

            if (!bSameComputerOrDomain)

            { 

                m_sSecureTokenForHTML5 = Session.SessionID; //Have to pass it as a parameter to player javascript, cookie will not work

                m_sSecureTokenForHTML5File = "/sid:" + Session.SessionID;

            }

 

            if(Session["Username"] != null)

                Welcome.Text = "Hello, " + Session["Username"].ToString() + "!";

            else

                Response.Redirect("login.aspx");

        }

 

        protected void Signout_Click(object sender, EventArgs e)

        {

            try

            {

                // When a user signs out we have to remove his session ID from

                // Media Server session manager.

 

                // We can do it using COM call or using Restful Web API call. If your Media Server is on the same machine with the Web Server, just use COM.

                // Otherwise, you can configure DCOM to make a COM call to a different machine, or, preferably, use Restful Web API call to a different machine.

 

                bool bUseCOM = false;   //We will call Restful Web API, but you can change it to COM

 

                if (bUseCOM)

                {

                    ExternalSession MediaServerSessionMngr = new ExternalSession();

                    MediaServerSessionMngr.RemoveSession(Session.SessionID);

                }

                else

                {

                    //Send HTTP request over HTTP or HTTPS

                    string sIPAddress = "127.0.0.1";

                    string sPassword = "MyPassword";

 

                    bool bWebAPIOverHTTPS = false;  //Change this to true if you want to send request over HTTPS

 

                    bool bSecure = bWebAPIOverHTTPS ? true : false;

                    bool bIgnoreCertificateErrors = bWebAPIOverHTTPS ? true : false;

                    string sPort = bWebAPIOverHTTPS ? "443" : "5119";

 

                    //Last two parameters don't matter for RemoveSession

                    Global.SessionBasedAuthentication_WebAPI(sIPAddress, bSecure, bIgnoreCertificateErrors, sPort, sPassword, "RemoveSession", Session.SessionID, "", false, false);

                }

 

                FormsAuthentication.SignOut();

            }

            catch (Exception ex)

            {

            }

 

            Response.Redirect("login.aspx");

        }        

    }

}

 

 

Default.aspx.designer.cs

 

//------------------------------------------------------------------------------

// <auto-generated>

//     This code was generated by a tool.

//

//     Changes to this file may cause incorrect behavior and will be lost if

//     the code is regenerated. 

// </auto-generated>

//------------------------------------------------------------------------------

 

namespace USessionAuth {

    

    

    public partial class _Default {

        

        /// <summary>

        /// Form control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.HtmlControls.HtmlForm Form;

        

        /// <summary>

        /// Welcome control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.Label Welcome;

        

        /// <summary>

        /// Button1 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.Button Button1;

    }

}

 

Default.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="USessionAuth._Default" %>

 

<html xmlns="http://www.w3.org/1999/xhtml" >

    

   <head>

   <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

   <script type="text/javascript" src="http://www.umediaserver.net/umediaplayer7.js"></script>

   <!--<link rel="stylesheet" href="http://www.umediaserver.net/umediaserver/unreal_html5_player_styles_v1.css" />-->

   <script src="http://www.umediaserver.net/umediaserver/unreal_html5_player_script_v2.js" type="text/javascript"></script>

   <script src="http://www.umediaserver.net/umediaserver/webrtcadapter.js" type="text/javascript"></script>

   <script src="http://www.umediaserver.net/umediaserver/unrealwebrtcplayer.js" type="text/javascript"></script>

   <script type="text/javascript" src="http://www.umediaserver.net/bin/FlashPlayer/umsplayer.js" charset="utf-8"></script>

   </head>

    <body>

        <h4>

        <font face="Verdana">Session-based Authentication</font>

        </h4>

 

        <form id="Form" runat=server>

            <asp:label id="Welcome" runat=server Font-Bold="True" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:button ID="Button1" text="Signout" OnClick="Signout_Click" runat=server Font-Bold="True" /><br><br>

            This example assumes you have a live broadcast with alias "webcam", encoded with H.264/AAC/Opus codecs and configured to use Session-Based authentication.<br>

This example also assumes you have a file test.mp4 residing in virtual folder "mediaroot" which is configured to use Session-Based authentication.<br>

Note that AAC audio will play in all players except WebRTC player; Opus audio will play in WebRTC player and Unreal Streaming player's browser plugin.

        </form>

        

        <table cellpadding="20px">

            <tr>

                

                <td><font color="red">WebRTC HTML5 Player:</font><br><br>

                    <video style="background-color:black" id="remoteVideo" width="600" height="400" autoplay playsinline controls></video>

                    <script type="text/javascript">

                        var webrtcPlayer = new UnrealWebRTCPlayer("remoteVideo", "webcam", "<%=m_sSecureTokenForHTML5%>", "<%=Request.ServerVariables["SERVER_NAME"].ToString()%>", "5119", false, true, "udp");

webrtcPlayer.Play();

                    </script>

                </td>

 

<td><font color="red">HTML5 MSE Player:</font><br><br>

                    <UnrealHTML5VideoPlayer id="UnrealPlayer1"></UnrealHTML5VideoPlayer>

                    <script type="text/javascript">

                        RunPlayer("UnrealPlayer1", 600, 400, "<%=Request.ServerVariables["SERVER_NAME"].ToString()%>", 5119, false, "webcam", "<%=m_sSecureTokenForHTML5%>", true, false, 1, "", false);

                    </script>

                </td>

 

            </tr>

 

<tr>

 

<td><font color="red">Flash Player:</font><br><br>

                    <div id="player-container"></div>

                    <script type="text/javascript">

                        embedPlayer('player-container', {

                            flashvars: {

                            'rtmp': 'rtmp://<%=Request.ServerVariables["SERVER_NAME"].ToString()%>:5119/live/webcam\\\\\\SID:<%=Session.SessionID.ToString()%>',

                                'autoplay': true,

                                'showMetadata': true,

                                'showLiveCaption': true,

                                'livelabelshowbg': false,

                                'showErrorInPlayer': true

                            },

                            size: { width: 600, height: 400 },

                            playerStyle: 'quick'

                        });

                    </script>

                </td>

 

                <td><font color="red">Unreal Player:</font><br><br>

                    <script type="text/javascript">

                        var po = new PlayerObject("player");

                        po.createPlayer(600, 400);

                        po.object = document.getElementById("player");

                        po.initPlayer();

                        po.object.UseMediaServer("<%=Request.ServerVariables["SERVER_NAME"].ToString()%>:5119");

                        po.object.UseLiveAlias("webcam");

                        po.object.UseSessionID("<%=Session.SessionID.ToString()%>");

                        po.object.Play();

                    </script>

                </td>

                

            </tr>

            

            <tr>

                <td><font color="red">test.mp4 file in video element:</font><br><br>

                    <video style="background-color:black" id="remoteVideoFile" src="http://<%=Request.ServerVariables["SERVER_NAME"].ToString()%>:5119/UnrealHTML5File/MediaRoot/test.mp4<%=m_sSecureTokenForHTML5File%>" type="video/mp4" width="600" height="400" autoplay playsinline controls></video>

                </td>

                <td>

                        <br>

                        <a href="ums:\\TCP:<%=Request.ServerVariables["SERVER_NAME"].ToString()%>\webcam\\\SID:<%=Session.SessionID.ToString()%>" target="_new">UMS link for playing in a standalone Unreal Streaming Media Player</a><br><br>

                        RTMP link for for Flash players:<br>

                        <font color=blue>rtmp://<%=Request.ServerVariables["SERVER_NAME"].ToString()%>:5119/live/webcam\\\SID:<%=Session.SessionID.ToString()%></font>

                </td>

            </tr>

            

        </table>

  

    </body>

</html>

 

 

GetCounters.aspx.cs

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace USessionAuth

{

    public partial class GetCounters : System.Web.UI.Page

    {

        public string m_sCounters = "";

        protected void Page_Load(object sender, EventArgs e)

        {

        }

 

        protected void GetCounters_Click(object sender, EventArgs e)

        {

            string sIPAddress = "127.0.0.1";

            string sPassword = "MyPassword";

 

            bool bWebAPIOverHTTPS = false;  //Change this to true if you want to send request over HTTPS

 

            bool bSecure = bWebAPIOverHTTPS ? true : false;

            bool bIgnoreCertificateErrors = bWebAPIOverHTTPS ? true : false;

            string sPort = bWebAPIOverHTTPS ? "443" : "5119";

 

            Global.GetLoadMetrics_WebAPI(sIPAddress, bSecure, bIgnoreCertificateErrors, sPort, sPassword, ref m_sCounters);

        }

    }

}

 

GetCounters.aspx.designer.cs

 

//------------------------------------------------------------------------------

// <auto-generated>

//     This code was generated by a tool.

//

//     Changes to this file may cause incorrect behavior and will be lost if

//     the code is regenerated. 

// </auto-generated>

//------------------------------------------------------------------------------

 

namespace USessionAuth {

    

    

    public partial class GetCounters {

        

        /// <summary>

        /// form1 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.HtmlControls.HtmlForm form1;

        

        /// <summary>

        /// Button1 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.Button Button1;

    }

}

 

GetCounters.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetCounters.aspx.cs" Inherits="USessionAuth.GetCounters" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

        <h4>

            <font face="Verdana">Web API to retrieve current server load</font><br><br>

            <asp:button ID="Button1" text="Get Counters" OnClick="GetCounters_Click" runat=server Font-Bold="True" />&nbsp;&nbsp;&nbsp;<%=m_sCounters%>

        <h4>

        </form>

</body>

</html>

 

Global.asax.cs

 

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.Security;

using System.Web.SessionState;

using System.Net;

using System.IO;

using System.Text;

using System.Net.Security;

using System.Security.Cryptography;

using System.Security.Cryptography.X509Certificates;

using UMEDIASERVERLib;

 

namespace USessionAuth

{

    public class Global : System.Web.HttpApplication

    {

 

        protected void Application_Start(object sender, EventArgs e)

        {

 

        }

 

        protected void Session_Start(object sender, EventArgs e)

        {

 

        }

 

        protected void Application_BeginRequest(object sender, EventArgs e)

        {

 

        }

 

        protected void Application_AuthenticateRequest(object sender, EventArgs e)

        {

 

        }

 

        protected void Application_Error(object sender, EventArgs e)

        {

 

        }

 

        protected void Session_End(object sender, EventArgs e)

        {

            try

            {

                // When session expires we need to remove session ID from MediaServer session manager.

                // It's ok to call RemoveSession twice (if the session has been previously removed when user clicked on Signout button).

                // The second call will just do nothing 

                if (Session["Username"] != null)

                {

                    Session["Username"] = null;

                    ExternalSession MediaServerSessionMngr = new ExternalSession();

                    MediaServerSessionMngr.RemoveSession(Session.SessionID.ToString());

                }

            }

            catch (Exception ex)

            {

            }

        }

 

        protected void Application_End(object sender, EventArgs e)

        {

 

        }

 

        public static bool SessionBasedAuthentication_WebAPI(string sServerIP, bool bSecure, bool bIgnoreCertificateErrors, string sServerPort, string sServerPassword, string sCommand, string sUserToken, string sUserName, bool bSameComputerOrDomain, bool bAllowHTML5PlayersOnly)

        {

            try

            {

                string sURI = bSecure ? "https://" : "http://";

                sURI += sServerIP + ":" + sServerPort + "/webapi";

                Guid newGuid = Guid.NewGuid();

                sURI += "_" + newGuid.ToString().Replace("-", "1");

 

                //Must use TLS 1.1 or higher

                if (bSecure)

                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

 

                WebRequest request = WebRequest.Create(sURI);

 

                if (bSecure && bIgnoreCertificateErrors)

                    SSLValidator.OverrideValidation();

 

                string sSIDMode = "0";

                if (bSameComputerOrDomain)

                    sSIDMode = (bAllowHTML5PlayersOnly)? "2" : "1";

 

                string sMessage = "Command=" + sCommand + "&Password=" + sServerPassword + "&SecureToken=" + sUserToken;

                if (sUserName.Length > 0)

                    sMessage += "&UserName=" + sUserName;

                if (sSIDMode != "0")

                    sMessage += "&SIDMode=" + sSIDMode;

 

                string Base64Message = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sMessage));

 

                ((HttpWebRequest)request).Headers.Add("UMediaWebAPI", Base64Message);

 

                WebResponse response = request.GetResponse();

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)

                    return true;

                else

                    return false;

            }

            catch

            {

                return false;

            }

        }

 

        public static bool GetLoadMetrics_WebAPI(string sServerIP, bool bSecure, bool bIgnoreCertificateErrors, string sServerPort, string sServerPassword, ref string sCounters)

        {

            sCounters = "";

 

            try

            {

                string sURI = bSecure ? "https://" : "http://";

                sURI += sServerIP + ":" + sServerPort + "/webapi";

                Guid newGuid = Guid.NewGuid();

                sURI += "_" + newGuid.ToString().Replace("-", "1");

 

                //Must use TLS 1.1 or higher

                if (bSecure)

                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

 

                WebRequest request = WebRequest.Create(sURI);

 

                if (bSecure && bIgnoreCertificateErrors)

                    SSLValidator.OverrideValidation();

 

                string sMessage = "Command=GetLoadMetrics&Password=" + sServerPassword;

 

                string Base64Message = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sMessage));

 

                ((HttpWebRequest)request).Headers.Add("UMediaWebAPI", Base64Message);

 

                WebResponse response = request.GetResponse();

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)

                {

                    Stream receiveStream = ((HttpWebResponse)response).GetResponseStream();

                    StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.GetEncoding("utf-8"));

                    sCounters = readStream.ReadToEnd();

                    readStream.Close();

 

                    return true;

                }

                else

                {

                    return false;

                }

            }

            catch

            {

                return false;

            }

        }

 

        public static class SSLValidator

        {

            private static bool OnValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }

            public static void OverrideValidation() { ServicePointManager.ServerCertificateValidationCallback = OnValidateCertificate; }

        }

    }

}

 

 

Global.asax

 

<%@ Application Codebehind="Global.asax.cs" Inherits="USessionAuth.Global" Language="C#" %>

 

 

Login.aspx.cs

 

using System;

using System.Collections.Generic;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.Security;

using UMEDIASERVERLib;

 

namespace USessionAuth

{

    public partial class Login : System.Web.UI.Page

    {

        protected void Login_Click(Object sender, EventArgs E)

        {

            // There are 3 users for whom streaming video is allowed. 

            // Of course it's not the way to store user's credentials.

            // This is for demonstration purposes only.

 

            if ((AccountName.Value == "video") && (UserPass.Value == "pass") ||

                (AccountName.Value == "user") && (UserPass.Value == "video") ||

                (AccountName.Value == "guest") && (UserPass.Value == "guest"))

            {

                Session["Username"] = AccountName.Value;

 

                // Before redirecting to a page with video players, we have to add some per-user secure token (the easiest is Session ID), to Unreal Media Server.

                // We can do it using COM call or using Restful Web API call. If your Media Server is on the same machine with the Web Server, just use COM.

                // Otherwise, you can configure DCOM to make a COM call to a different machine, or, preferably, use Restful Web API call to a different machine.

 

                bool bSameComputerOrDomain = true; //Media Server and Web Server run on the same computer or domain

 

                // The same secure token needs to be passed back to HTML page, so that the players can attach it to play request.

                // For HTML5 players, the secure token should be passed via cookie: this way it cannot be used by 3rd party if stolen.

                if (bSameComputerOrDomain)

                {

                    //Cookie will work only if Media Server and Web Server run on the same computer or domain

                    //If you want to use a cookie already existing in your web app, then you don't need the below 3 lines. In this case, on your Media Server computer, create STRING registry value under HKLM\SOFTWARE\UNREAL\SERVER, name it "SessionBasedAuthCookieName" and set to your cookie name.

                    HttpCookie HttpOnlyCookie = new HttpCookie("UMS_AuthToken", Session.SessionID);

                    HttpOnlyCookie.HttpOnly = true;

                    //HttpOnlyCookie.Domain = ""; //If your Web Server and Media Server run on different subdomains, you may want to set it here

                    Response.AppendCookie(HttpOnlyCookie);

                }

 

                bool bUseCOM = false;   //We will call Restful Web API, but you can change it to COM

 

                bool bAllowHTML5PlayersOnly = false;    //Set to true to disallow any other players except HTML5.

 

                if (bUseCOM)

                {

                    try

                    {

                        if (bSameComputerOrDomain)

                        {

                            //Secure token will be passed by player in HTML cookie

                            ExternalSession MediaServerSessionMngr = new ExternalSession();

                            MediaServerSessionMngr.AddSessionEx(Session.SessionID, AccountName.Value, bAllowHTML5PlayersOnly, "");

                            FormsAuthentication.RedirectFromLoginPage(AccountName.Value, false);

                        }

                        else

                        {

                            //Secure token will be passed by player attached to play request URL - less secure

                            ExternalSession MediaServerSessionMngr = new ExternalSession();

                            MediaServerSessionMngr.AddSession(Session.SessionID, AccountName.Value);

                            FormsAuthentication.RedirectFromLoginPage(AccountName.Value, false);

                        }

                    }

                    catch

                    {

                        Msg.Text = "COM Error calling AddSession method of the server";

                    }

                }

                else

                {

                    //Send HTTP request over HTTP or HTTPS

                    string sIPAddress = "127.0.0.1";

                    string sPassword = "MyPassword";    //Make sure this is the password configured in the Media Server properties

 

                    bool bWebAPIOverHTTPS = false;  //Change this to true if you want to send AddSession request over HTTPS

 

                    bool bSecure = bWebAPIOverHTTPS ? true : false;

                    bool bIgnoreCertificateErrors = bWebAPIOverHTTPS ? true : false;

                    string sPort = bWebAPIOverHTTPS ? "443" : "5119";

 

                    if (Global.SessionBasedAuthentication_WebAPI(sIPAddress, bSecure, bIgnoreCertificateErrors, sPort, sPassword, "AddSession", Session.SessionID, AccountName.Value, bSameComputerOrDomain, bAllowHTML5PlayersOnly))

                        FormsAuthentication.RedirectFromLoginPage(AccountName.Value, false);

                    else

                        Msg.Text = "Error sending AddSession command to the server";

                }

            }

            else

            {

                Msg.Text = "Invalid Credentials: Please try again";

            }

        }

    }

}

 

 

Login.aspx.designer.cs

 

//------------------------------------------------------------------------------

// <auto-generated>

//     This code was generated by a tool.

//

//     Changes to this file may cause incorrect behavior and will be lost if

//     the code is regenerated. 

// </auto-generated>

//------------------------------------------------------------------------------

 

namespace USessionAuth {

    

    

    public partial class Login {

        

        /// <summary>

        /// Form1 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.HtmlControls.HtmlForm Form1;

        

        /// <summary>

        /// AccountName control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.HtmlControls.HtmlInputText AccountName;

        

        /// <summary>

        /// RequiredFieldValidator1 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;

        

        /// <summary>

        /// UserPass control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.HtmlControls.HtmlInputPassword UserPass;

        

        /// <summary>

        /// RequiredFieldValidator2 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;

        

        /// <summary>

        /// Button1 control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.Button Button1;

        

        /// <summary>

        /// Msg control.

        /// </summary>

        /// <remarks>

        /// Auto-generated field.

        /// To modify move field declaration from designer file to code-behind file.

        /// </remarks>

        protected global::System.Web.UI.WebControls.Label Msg;

    }

}

 

 

Login.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="USessionAuth.Login" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title></title>

</head>

<body>

    <form id="Form1" runat=server>

        <center>

        <h3>

        <font face="Verdana" color=blue>Login Page</font>

        </h3>

        <table>

            <tr>

                <td>

                    Account:

                </td>

                <td>

                    <input id="AccountName" 

                    type="text" 

                    runat=server 

                    size=30 />

                </td>

                <td>

                    <ASP:RequiredFieldValidator ID="RequiredFieldValidator1" 

                        ControlToValidate="AccountName" 

                        Display="Static" ErrorMessage="*" 

                        runat=server />

                </td>

            </tr>

            <tr>

                <td>

                    Password:

                </td>

                <td>

                    <input id="UserPass" 

                    type=password 

                    runat=server size=31 />

                </td>

                <td>

                    <ASP:RequiredFieldValidator ID="RequiredFieldValidator2" 

                        ControlToValidate="UserPass" 

                        Display="Static" ErrorMessage="*" 

                        runat=server />

                </td>

            </tr>

            <tr>

                <td colspan=3 align="center">

                    <asp:button ID="Button1" text="Login" 

                        OnClick="Login_Click" 

                        runat=server>

                    </asp:button>

                    <p>

                    <asp:Label id="Msg" ForeColor="red" 

                    Font-Name="Verdana" 

                    Font-Size="10" runat=server />

                </td>

            </tr>

        </table>

            <br><a href="GetCounters.aspx" target="new">Web API to retrieve current server load</a>

        </center>

    </form>

    </body>

</html>

 

 

USessionAuth.csproj

 

<?xml version="1.0" encoding="utf-8"?>

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

  <PropertyGroup>

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

    <ProductVersion>9.0.30729</ProductVersion>

    <SchemaVersion>2.0</SchemaVersion>

    <ProjectGuid>{0F411691-3343-4977-8EBF-07860C723875}</ProjectGuid>

    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

    <OutputType>Library</OutputType>

    <AppDesignerFolder>Properties</AppDesignerFolder>

    <RootNamespace>USessionAuth</RootNamespace>

    <AssemblyName>USessionAuth</AssemblyName>

    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

    <FileUpgradeFlags>

    </FileUpgradeFlags>

    <UpgradeBackupLocation>

    </UpgradeBackupLocation>

    <OldToolsVersion>3.5</OldToolsVersion>

    <TargetFrameworkProfile />

    <UseIISExpress>false</UseIISExpress>

    <IISExpressSSLPort />

    <IISExpressAnonymousAuthentication />

    <IISExpressWindowsAuthentication />

    <IISExpressUseClassicPipelineMode />

    <UseGlobalApplicationHostFile />

  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

    <DebugSymbols>true</DebugSymbols>

    <DebugType>full</DebugType>

    <Optimize>false</Optimize>

    <OutputPath>bin\</OutputPath>

    <DefineConstants>DEBUG;TRACE</DefineConstants>

    <ErrorReport>prompt</ErrorReport>

    <WarningLevel>4</WarningLevel>

    <Prefer32Bit>false</Prefer32Bit>

  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

    <DebugType>pdbonly</DebugType>

    <Optimize>true</Optimize>

    <OutputPath>bin\</OutputPath>

    <DefineConstants>TRACE</DefineConstants>

    <ErrorReport>prompt</ErrorReport>

    <WarningLevel>4</WarningLevel>

    <Prefer32Bit>false</Prefer32Bit>

  </PropertyGroup>

  <ItemGroup>

    <Reference Include="System" />

    <Reference Include="System.Data" />

    <Reference Include="System.Data.DataSetExtensions" />

    <Reference Include="System.Drawing" />

    <Reference Include="System.Web" />

    <Reference Include="System.Web.ApplicationServices" />

    <Reference Include="System.Web.DynamicData" />

    <Reference Include="System.Web.Entity" />

    <Reference Include="System.Web.Extensions" />

    <Reference Include="System.Xml" />

    <Reference Include="System.Configuration" />

    <Reference Include="System.Web.Services" />

    <Reference Include="System.EnterpriseServices" />

    <Reference Include="System.Web.Mobile" />

    <Reference Include="System.Xml.Linq" />

  </ItemGroup>

  <ItemGroup>

    <Content Include="Default.aspx" />

    <Content Include="GetCounters.aspx" />

    <Content Include="Global.asax" />

    <Content Include="Login.aspx" />

    <Content Include="Web.config" />

  </ItemGroup>

  <ItemGroup>

    <Compile Include="Default.aspx.cs">

      <SubType>ASPXCodeBehind</SubType>

      <DependentUpon>Default.aspx</DependentUpon>

    </Compile>

    <Compile Include="Default.aspx.designer.cs">

      <DependentUpon>Default.aspx</DependentUpon>

    </Compile>

    <Compile Include="GetCounters.aspx.cs">

      <DependentUpon>GetCounters.aspx</DependentUpon>

      <SubType>ASPXCodeBehind</SubType>

    </Compile>

    <Compile Include="GetCounters.aspx.designer.cs">

      <DependentUpon>GetCounters.aspx</DependentUpon>

    </Compile>

    <Compile Include="Global.asax.cs">

      <DependentUpon>Global.asax</DependentUpon>

    </Compile>

    <Compile Include="Login.aspx.cs">

      <DependentUpon>Login.aspx</DependentUpon>

      <SubType>ASPXCodeBehind</SubType>

    </Compile>

    <Compile Include="Login.aspx.designer.cs">

      <DependentUpon>Login.aspx</DependentUpon>

    </Compile>

    <Compile Include="Properties\AssemblyInfo.cs" />

  </ItemGroup>

  <ItemGroup>

    <COMReference Include="UMEDIASERVERLib">

      <Guid>{57773F98-0D70-4748-BB78-FE73745FFB64}</Guid>

      <VersionMajor>1</VersionMajor>

      <VersionMinor>0</VersionMinor>

      <Lcid>0</Lcid>

      <WrapperTool>tlbimp</WrapperTool>

      <Isolated>False</Isolated>

    </COMReference>

  </ItemGroup>

  <ItemGroup>

    <Folder Include="App_Data\" />

  </ItemGroup>

  <PropertyGroup>

    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

  </PropertyGroup>

  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

       Other similar extension points exist, see Microsoft.Common.targets.

  <Target Name="BeforeBuild">

  </Target>

  <Target Name="AfterBuild">

  </Target>

  -->

  <ProjectExtensions>

    <VisualStudio>

      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">

        <WebProjectProperties>

          <UseIIS>False</UseIIS>

          <AutoAssignPort>True</AutoAssignPort>

          <DevelopmentServerPort>20017</DevelopmentServerPort>

          <DevelopmentServerVPath>/</DevelopmentServerVPath>

          <IISUrl>

          </IISUrl>

          <NTLMAuthentication>False</NTLMAuthentication>

          <UseCustomServer>False</UseCustomServer>

          <CustomServerUrl>

          </CustomServerUrl>

          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>

        </WebProjectProperties>

      </FlavorProperties>

    </VisualStudio>

  </ProjectExtensions>

</Project>

 

USessionAuth.csproj.user

 

<?xml version="1.0" encoding="utf-8"?>

<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>

    <UseIISExpress>false</UseIISExpress>

  </PropertyGroup>

  <ProjectExtensions>

    <VisualStudio>

      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">

        <WebProjectProperties>

          <StartPageUrl>

          </StartPageUrl>

          <StartAction>CurrentPage</StartAction>

          <AspNetDebugging>True</AspNetDebugging>

          <SilverlightDebugging>False</SilverlightDebugging>

          <NativeDebugging>False</NativeDebugging>

          <SQLDebugging>False</SQLDebugging>

          <ExternalProgram>

          </ExternalProgram>

          <StartExternalURL>

          </StartExternalURL>

          <StartCmdLineArguments>

          </StartCmdLineArguments>

          <StartWorkingDirectory>

          </StartWorkingDirectory>

          <EnableENC>True</EnableENC>

          <AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>

        </WebProjectProperties>

      </FlavorProperties>

    </VisualStudio>

  </ProjectExtensions>

</Project>

 

USessionAuth.sln

 

 

Microsoft Visual Studio Solution File, Format Version 12.00

# Visual Studio 14

VisualStudioVersion = 14.0.25420.1

MinimumVisualStudioVersion = 10.0.40219.1

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "USessionAuth", "USessionAuth.csproj", "{0F411691-3343-4977-8EBF-07860C723875}"

EndProject

Global

GlobalSection(SolutionConfigurationPlatforms) = preSolution

Debug|Any CPU = Debug|Any CPU

Release|Any CPU = Release|Any CPU

EndGlobalSection

GlobalSection(ProjectConfigurationPlatforms) = postSolution

{0F411691-3343-4977-8EBF-07860C723875}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

{0F411691-3343-4977-8EBF-07860C723875}.Debug|Any CPU.Build.0 = Debug|Any CPU

{0F411691-3343-4977-8EBF-07860C723875}.Release|Any CPU.ActiveCfg = Release|Any CPU

{0F411691-3343-4977-8EBF-07860C723875}.Release|Any CPU.Build.0 = Release|Any CPU

EndGlobalSection

GlobalSection(SolutionProperties) = preSolution

HideSolutionNode = FALSE

EndGlobalSection

EndGlobal

 

 

Web.config

 

<configuration>

<!--

For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

 

The following attributes can be set on the <httpRuntime> tag.

<system.Web>

<httpRuntime targetFramework="4.5" />

</system.Web>

-->

<system.web>

<authentication mode="Forms">

<forms name=".ASPXUSESSIONAUTHDEMO" loginUrl="login.aspx" protection="All" timeout="20"/>

</authentication>

<authorization>

<deny users="?"/>

</authorization>

<trace enabled="false" pageOutput="false"/>

<globalization requestEncoding="UTF-8" responseEncoding="UTF-8"/>

<compilation debug="true" targetFramework="4.5"/>

<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>

  </system.web>

  <location path="GetCounters.aspx">

    <system.web>

      <authorization>

        <allow users ="*" />

      </authorization>

    </system.web>

  </location>

</configuration>