1

I'm trying to pass coordinates to an html file through a hyperlink, but the "?=" part seems to get overridden.

<TextBlock><Hyperlink x:Name="hl" NavigateUri="C:/Users/.../RESTToolkitTestApp/index.htm" RequestNavigate="Hyperlink_RequestNavigate">HyperLink</Hyperlink></TextBlock>

this is in my xaml file

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            String coords = coord1 + " " + coord2;
            String tempurl = e.Uri.AbsoluteUri + "?test=0";
            Process.Start(new ProcessStartInfo(tempurl, coords));
            e.Handled = true;
        }

this is in my c# file

When I click on the hyperlink the "?test=0" goes away, I think probably because of the NavigateUri has a set url and the Process parameters don't actually do anything? I tried passing coords on as a parameter too as you can see in the line "Process.Start", but I don't know how to receive it on the htm side. If you know how to get the data from the htm file either way, or maybe some other way, I would appreciate it.

Marcus
  • 116
  • 11
  • This might help. https://stackoverflow.com/questions/8757585/why-doesnt-system-uri-recognize-query-parameter-for-local-file-path. I'm not sure either what querystring parameters are for in a local file. Does some JavaScript that executes in the file use them? – Scott Hannen Jul 05 '22 at 17:09
  • You can't pass query parameters to a file URL. They aren't part of the file path – Panagiotis Kanavos Jul 05 '22 at 17:21

1 Answers1

0

You can try like below:

Uri fileUri = new Uri("file:YourFilePath?test=0");
Abdus Salam Azad
  • 5,087
  • 46
  • 35
  • For a local file it seems like adding a querystring is impossible? At least this method does not work. – Marcus Jul 05 '22 at 22:04