frosty
How to retrieve a machine name in a Silverlight Application
by
, 09-13-2011 at 02:26 PM (1206 Views)
Silverlight itself does not provide a way to do this. However, since Silverlight is hosted in Asp.Net, we can use InitParams to get the host name.
First whatever your asp.net landing page is, add a public property called HostName.
In the Page_Load event, we assign a value to HostName.
In the default.aspx code, add the following to the initParms:Code:public string HostName { get; set; } protected void Page_Load(object sender, EventArgs e) { HostName = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName; }
Finally, in the App.Xaml.cs, Application_Startup() event, add the following code.Code:<param name="initParams" value="<%= string.Format("HostName={0}", HostName) %>" />
You should have the FQDN of the host machine running the silverlight app.Code:string _hostName = e.InitParams["HostName"];







Email Blog Entry

