<p>In order for my application (.Net 1.1) to use the system configured proxy server (trough a proxy.pac script) I was using an interop calls to WinHTTP function WinHttpGetProxyForUrl, passing the proxy.pac url I got from the registry.</p>

<p>Unfortunately, I hit a deployment scenario, where this does not work, as the proxy.pac file is deployed locally on the user's hard drive, and the url is "file://C://xxxx"</p>

<p>As clearly stated in the WinHttpGetProxyForUrl docs, it works only with http and https schemes, so it fails with file://</p>

<p>I'm considering 2 "ugly" solutions to the problem (the pac file is javascript):</p>

<ol>
<li><p>Creating a separate JScript.NET project, with a single class with single static method Eval(string), and use it to eval in runtime the function read from the pac file</p></li>
<li><p>Building at runtime a JScript.NET assembly and load it.</p></li>
</ol>

<p>As these solutions are really ugly :), does anybody know a better approach? Is there a Windows function which I can use trough interop?</p>

<p>If not, what are you guys thinking about the above 2 solutions - which one would you prefer?</p>

[{'answer_id': 64143, 'author': 'chrisb', 'author_id': 8262, 'author_profile': 'https://Stackoverflow.com/users/8262', 'pm_score': 0, 'selected': False, 'text': "<p>Can't answer your problem unfortunately (though a few years ago I played with jscript.net and it would only be a few lines to build and run that way)</p>\n\n<p>I hit a similar proxy.pac hiccup with a personal work-around-the-office-proxy file a while back - in the end I went with the easiest option and dropped it into its own IIS site, and its been rock solid and works flawlessly with everything on my pc.</p>\n\n<p>Sometimes its best to give in and work with what is provided :)</p>\n"}, {'answer_id': 227601, 'author': 'benc', 'author_id': 2910, 'author_profile': 'https://Stackoverflow.com/users/2910', 'pm_score': 0, 'selected': False, 'text': "<p>I can't answer you question directly, but working from the mozilla implementation there was a definite debate about supporting file URLs. It was a network control vs. local user convenience debate.</p>\n"}, {'answer_id': 317877, 'author': 'Frank Taylor', 'author_id': 28164, 'author_profile': 'https://Stackoverflow.com/users/28164', 'pm_score': 3, 'selected': True, 'text': '<p>Just a thought: Why not create a micro web server that can serve the local PAC file over a localhost socket. You should use a random URI for the content so that it is difficult to browse this in unexpected ways.</p>\n\n<p>You could then pass a URL like <a href="http://localhost:1234/gfdjklskjgfsdjgklsdfklgfsjkl" rel="nofollow noreferrer">http://localhost:1234/gfdjklskjgfsdjgklsdfklgfsjkl</a> to the WinHttpGetProxyForUrl function and allow it to pull the PAC file from your micro server.</p>\n\n<p>(hack... hack... hack...)</p>\n'}, {'answer_id': 1529338, 'author': 'EricLaw', 'author_id': 126229, 'author_profile': 'https://Stackoverflow.com/users/126229', 'pm_score': 1, 'selected': False, 'text': '<p>FWIW: <a href="https://web.archive.org/web/20150405115150/http://msdn.microsoft.com/en-us/magazine/cc300743.aspx" rel="nofollow noreferrer">https://web.archive.org/web/20150405115150/http://msdn.microsoft.com/en-us/magazine/cc300743.aspx</a> describes how to use the JScript.NET engine to do this securely.</p>\n\n<p><a href="https://web.archive.org/web/20090220132508/http://msdn.microsoft.com/en-us/library/aa383910(VS.85).aspx" rel="nofollow noreferrer">https://web.archive.org/web/20090220132508/http://msdn.microsoft.com/en-us/library/aa383910(VS.85).aspx</a> explains how to use WinINET\'s implementation.</p>\n'}]
['https://Stackoverflow.com/questions/64092', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8220/']