I am trying to use a hyperlinkbutton in silverlight to enable the user to download a word document. I don't care if a file save as box appears or if the word doc opens in a new browser. I get the error "cannot navigate to locations relative to a page." I've seen it posted that you can do this with the absolute path (www.domain.com/filename.doc) but there's got to be a way to make this relative (/docs/filename.doc). Anyone know how?
+4
A:
The HyperlinkButton only works with absolute URLS, so you should fixup your URLs at runtime:
uriCurrent = System.Windows.Browser.HtmlPage.Document.DocumentUri;
string current = uriCurrent.OriginalString;
int iLastSlash = current.LastIndexOf('/') + 1;
current = current.Remove(iLastSlash, current.Length - iLastSlash);
from Silverlight.net forums.
Michael S. Scherotter
2009-01-02 18:21:00
Okay...that seems like it mostly solves my problem...is there a way to make that work with Cassini?
Scott Anderson
2009-01-04 06:25:05
Nevermind it works with Cassini too...I just had to append "ClientBin" in the path
Scott Anderson
2009-01-04 07:29:43
A:
Slightly easier:
Uri myAbsoluteUri = new Uri(HtmlPage.Document.DocumentUri, myRelativePath);
Anon99
2010-02-22 06:10:02