How can I add a request header to links to PDFs in WAB app?

578
4
04-04-2019 07:55 AM
ChrisMathers1
Occasional Contributor II

I have a WAB (developer edition, version 2.8) application showing features that have the URL of PDFs in a folder on my IIS10 webserver. When you hit one of the links it opens in a new tab so on the server I do not get any referrer information in IIS. I want to be able to log where the hits to the PDFs are coming from. Ultimately I would like to have the PDFs only available from within the app.

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Chris,

  Links in WAB just use a HTML anchor element so no you can not set a request header. If your goal is to restrict access to a certain url then look at this thread:

https://forums.iis.net/t/1171154.aspx

0 Kudos
ChrisMathers1
Occasional Contributor II

The problem is that there is no referer. Browsers take the URL and send the GET from a new tab without any reference to the application. I've set up filters with URL Rewrite on REMOTE-ADDR when the client is all from a single IP but in this case the IP is the client wherever the link was clicked. I may have to result to adding a URL parameter in the popup definition to the links and catching that if I cant find a better thing to catch.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Chris,

   As I mentioned a HTML Anchor does not work with request headers so I am not sure what you can do beside re-write the HeaderController widget to not use HTML anchor elements for those links and use an xhr request or something instead.

0 Kudos
ChrisMathers1
Occasional Contributor II

Yeah that's what I want to avoid if I can. If it was already something I've developed I might consider going that route but I hate propagating tweaks between WAB versions. I think I'm going to go the route of custom popups in the AGOL map and tacking on a parameter to the end of the URL in the anchor. URL Rewrite can filter on parameters and the popup config is behind the in app Portal security so its hidden enough for me.