Get URI Of Silverlight Plugin Host Page
Within our Silverlight application if we want to know the URI where our Silverlight content is running, we can tap into System.Windows.Browser namespace. This namespace contains object which are full of Browser related information. This is an example of retrieving the URI from within Silverlight application.
<StackPanel x:Name="LayoutRoot" Margin="10"> <TextBlock Text="Your URL is: " /> <TextBlock Text="{Binding AbsoluteUri}" /> </StackPanel>
In our C# code we can set the DataContext so that the second TextBlock above displays the information we desire.
private void UserControl_Loaded(object sender, RoutedEventArgs e) { LayoutRoot.DataContext = System.Windows.Browser.HtmlPage.Document.DocumentUri; }
Here is my output which displays the URL at which my Silverlight plugin is hosted.
![]()
One Response to Get URI Of Silverlight Plugin Host Page
Leave a Reply Cancel reply
Top Posts
- LINQ To SQL Tutorial
- LINQ To SQL Join On Multiple Conditions
- Code Sample: Programmatically Download File Using C#
- Windows 7 Control Panel In Classic Mode
- More Details Emerge On Microsoft Master Certification
- Use SqlConnection With LINQ To SQL
- Free Icons And Images With Visual Studio 2008
- Capture XML In WCF Service
- Dynamic Sort With LINQ
- StyleCop Tutorial
Tags
.Net 2010 ADO.NET ASP.NET Azure Blogging Books Browsers C# Certification Cloud Computing Code Snippets Community Data Services Eclipse Entity Framework Google IDE Java LINQ Mac Microsoft Museum NetBeans Office Oracle REST SharePoint Silverlight SQL Server T-SQL Tips Tools Training Visual Studio Visual Studio 2010 WCF Web Windows Windows 7 Windows Forms Windows Live WMI WPF XAML


This was very handy.
One issue I am having is the URL changes depending on whether I am local or deployed to IIS:
http://localhost/SilverlightRestExampleTestPage.aspx“;
http://localhost//SilverlightRestExampleTestPage.aspx“;
I am trying to parse these so my Silverlight client can post back to the server it came from.
Know of an elegant way to just get the:
So I can dynamically build my URL on the client?
Thx, JR