Creating a Server Object in an ASP.NET Page

banner art

Previous Next

Creating a Server Object in an ASP.NET Page

You can create a WMSServer object in an ASP.NET page or a server-side script block.

Late Binding in an ASP.NET Page

The following two examples illustrate how to create a late-binding WMSServer object from the CLSID and the ProgID.

    < object id="wms" runat="server" classid="845FB958-4279-11D2-BF23-00805FBE84A6" />
    < object id="wms" runat="server" progid="WMSServer.Server" />

Early Binding in an ASP.NET Page

To create an early-binding WMSServer object that requires the Microsoft.WindowsMediaServices primary interop assembly, use code similar to the following. You must use the complete assembly name.

    < object id="wms" runat="server" 
             class="Microsoft.WindowsMediaServices.WMSServer,
             Microsoft.WindowsMediaServices, 
             Version=9.0.0.0,
             culture=neutral,
             PublicKeyToken=31bf3856ad364e35" />

Late Binding in a Server-side Script

You can use the HttpServerUtility.CreateObject or the HttpServerUtility.CreateObjectFromCLSID methods in the Microsoft® Windows® .NET Framework to create a late-binding WMSServer object. This is illustrated by the following C# examples.

// Create a local object from the ProgID.
WMSServer wms = (WMSSServer)Server.CreateObject("WMSServer.Server");

// Create a local object from the CLSID.
WMSServer wms = (WMSServer)Server.CreateObjectFromClsid("845FB958-4279-11D2-BF23-00805FBE84A6");

Early Binding in a Server-side Script

To take advantage of the Microsoft.WindowsMediaServices primary interop assembly and the performance benefits of early binding, you can use a System.Type object as illustrated in the following examples.

// Create a local WMSServer object from a System.Type object.
Type tServerType = Type.GetTypeFromProgID("WMSServer.Server");
WMSServer wms = (WMSServer)Activator.CreateInstance(tServerType);

// Create a remote WMSServer object from a System.Type object and 
// the CreateObject method.
Type tServerType = Type.GetTypeFromProgID("WMSServer.Server", "remote_server_name");
WMSServer wms = (WMSSServer)Server.CreateObject(tServerType);

// Create a remote WMSServer object from a System.Type object and a 
// System.Activator object.
Type tServerType = Type.GetTypeFromProgID("WMSServer.Server", "remote_server_name");
WMSServer wms = (WMSServer)Activator.CreateInstance(tServerType);

By default, Internet Information Services (IIS) uses Integrated Windows authentication which does not allow you to create a remote object. You must therefore configure IIS to use an authentication method that allows delegation (such as Basic authentication) and add the following tag to your Web.config file:

    < identity impersonate="true" />

Delegation allows IIS to impersonate your user account so that you can access objects on the remote computer. Integrated Windows authentication does not allow delegation, but Basic, Kerberos, and Digest do. That is, when the remote computer challenges a Web server that is using Integrated Windows authentication, IIS will not be able to impersonate your account and the remote computer will not let you create a WMSServer object. However, if you configure IIS to use Basic authentication, it will then be able to impersonate. Of course, you must have rights to create a WMSServer object on the remote computer. For more information about setting these rights, see Using DCOM to Customize Security Settings.

See Also

Previous Next