I have configured proxy and trying to consume a secured layer through proxy in Arcgis javascript.
When I test the proxy manually i get the response in web browser. That is to to say, when I enter the following Url in the broweser it returns a valid token :-
Token:
QBh62mCJxxyyXXyyCCCVVOdfDopSvrUX_4qq7IcMcpz2-U<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
URL :
http<SPAN class="punctuation token">:</SPAN><SPAN class="operator token">/</SPAN><SPAN class="operator token">/</SPAN>localhost<SPAN class="operator token">/</SPAN>DotNet<SPAN class="operator token">/</SPAN>proxy<SPAN class="punctuation token">.</SPAN>ashx<SPAN class="operator token">?</SPAN>http<SPAN class="punctuation token">:</SPAN><SPAN class="operator token">/</SPAN><SPAN class="operator token">/</SPAN><SPAN class="number token">00.00</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="number token">00</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">6080</SPAN><SPAN class="operator token">/</SPAN>arcgis<SPAN class="operator token">/</SPAN>tokens<SPAN class="operator token">?</SPAN>request<SPAN class="operator token">=</SPAN>gettoken<SPAN class="operator token">&</SPAN>username<SPAN class="operator token">=</SPAN>user<SPAN class="operator token">&</SPAN>password<SPAN class="operator token">=</SPAN><SPAN class="number token">123</SPAN><SPAN class="operator token">&</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
But through Javascript , gives an error :
dojo.io.script error Error: Token Required<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Javascript :
esriConfig<SPAN class="punctuation token">.</SPAN>defaults<SPAN class="punctuation token">.</SPAN>io<SPAN class="punctuation token">.</SPAN>proxyUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Flocalhost%2FDotNet%2Fproxy.ashx" target="_blank">http://localhost/DotNet/proxy.ashx</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">;</SPAN>
esri<SPAN class="punctuation token">.</SPAN>config<SPAN class="punctuation token">.</SPAN>defaults<SPAN class="punctuation token">.</SPAN>io<SPAN class="punctuation token">.</SPAN>alwaysUseProxy <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">;</SPAN>
urlSecuredlayer <SPAN class="operator token">=</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F00.00.00.00%3A6080%2Farcgis%2Frest%2Fservices%2FmyQuery%2Fmylayer%2FMapServer%2F0" target="_blank">http://00.00.00.00:6080/arcgis/rest/services/myQuery/mylayer/MapServer/0</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">;</SPAN>
Securedlayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">esri<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">.</SPAN>FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN>urlSecuredlayer<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"urlSecuredlayer"</SPAN><SPAN class="punctuation token">,</SPAN> mode<SPAN class="punctuation token">:</SPAN> esri<SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">.</SPAN>FeatureLayer<SPAN class="punctuation token">.</SPAN>MODE_ONDEMAND<SPAN class="punctuation token">,</SPAN> outFields<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
tiledLayer1 <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISTiledMapServiceLayer</SPAN><SPAN class="punctuation token">(</SPAN>urlsatellite<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"SatelitteMap"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
app<SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addLayer</SPAN><SPAN class="punctuation token">(</SPAN>tiledLayer1<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> states_Symbol <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">esri<SPAN class="punctuation token">.</SPAN>symbol<SPAN class="punctuation token">.</SPAN>SimpleFillSymbol</SPAN><SPAN class="punctuation token">(</SPAN>esri<SPAN class="punctuation token">.</SPAN>symbol<SPAN class="punctuation token">.</SPAN>SimpleFillSymbol<SPAN class="punctuation token">.</SPAN>STYLE_SOLID<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">esri<SPAN class="punctuation token">.</SPAN>symbol<SPAN class="punctuation token">.</SPAN>SimpleLineSymbol</SPAN><SPAN class="punctuation token">(</SPAN>esri<SPAN class="punctuation token">.</SPAN>symbol<SPAN class="punctuation token">.</SPAN>SimpleLineSymbol<SPAN class="punctuation token">.</SPAN>STYLE_SOLID<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">dojo<SPAN class="punctuation token">.</SPAN>Color</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">255</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">32</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">255</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0.35</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">dojo<SPAN class="punctuation token">.</SPAN>Color</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">255</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">65</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">125</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0.35</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
urlSecuredlayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setRenderer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">esri<SPAN class="punctuation token">.</SPAN>renderer<SPAN class="punctuation token">.</SPAN>SimpleRenderer</SPAN><SPAN class="punctuation token">(</SPAN>states_Symbol<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
app<SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">addLayers</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>Securedlayer<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Thank you for any help.