Using DotNet Proxy to Authenticate a Feature Service

460
1
Jump to solution
05-06-2021 12:52 PM
jaykapalczynski
Frequent Contributor

I have the DotNet Proxy installed and working for  url="https://route.arcgis.com/"  like in the example.

I am now trying to do this for a Feature Service in my App...but not working it keeps asking me for Credentials...

  1. I am not sure if I need to define the URL all the way to the index number or what....
  2. Do I need to define the Feature Service in the JS (part 3 below) differently to accept the token?

ANY HELP would be appreciated.

I created a Function that works for the first two and then tried to add my Feature Service

Do I need to define this URL to the index number????   /FeatureService/0/

 

window.jsWidgets = function(){

//SET UP PROXY RULE FOR ROUTING AND TRAFFIC
// https://community.esri.com/groups/technical-support/blog/2015/04/07/setting-up-a-proxy/

urlUtils.addProxyRule({
   urlPrefix: "route.arcgis.com",
   proxyUrl: "https://xxxx.xxx.xxx.gov/DotNet/proxy.ashx"
});
urlUtils.addProxyRule({
   urlPrefix: "traffic.arcgis.com",
   proxyUrl: "https://xxxx.xxx.xxx.gov/DotNet/proxy.ashx"
});
urlUtils.addProxyRule({
   urlPrefix: "https://xxxx.xxx.xxx.gov/arcgis/rest/services/Something/",
   proxyUrl: "https://xxxx.xxx.xxx.gov/DotNet/proxy.ashx"
});

}

 

 

Then in my proxy.config I added this

DO I need to define this URL to the index number????   /FeatureService/0/

 

<serverUrl url="https://xxxx.xxxx.xxxx.gov/arcgis/rest/services/Something/" 
			matchAll="true" username="User" password="U$er" tokenServiceUrl="https://xxxx.xxxx.xxxx.gov/arcgis/tokens/"/>

 

 

This is how I have the Feature Service in my JS

Do I need to reference a Token number or something?

 

		window.ServiceTest = new FeatureLayer("https://xxxx.xxxx.xxxx.gov/arcgis/rest/services/Something/ServiceName/FeatureServer/0", {
			mode: FeatureLayer.MODE_SNAPSHOT,
			id: "ServiceTest",
			opacity: .4,
			visible: true,
			outFields:["*"]
			});
		legendLayers4.push({ layer: ServiceTest, title: 'NWTL Test' });	

 

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
jaykapalczynski
Frequent Contributor

I got it....

<serverUrl url="https://xxxx.xxxx.xxxx.gov/arcgis/rest/services/Test/Test/FeatureServer/0"
matchAll="true" username="User" password="U$er"
tokenServiceUrl="https://xxxx.xxxx.xxxx.gov/arcgis/tokens/" />
urlUtils.addProxyRule({
urlPrefix: "https://xxxx.xxxx.xxxx.gov/arcgis/rest/services/Testing/Test/FeatureServer/0",
proxyUrl: "https://xxxx.xxxx.xxxx.gov/DotNet/proxy.ashx"
});
 window.ServiceTest = new FeatureLayer("https://xxxx.xxxx.xxx.gov/arcgis/rest/services/Testing/Test/FeatureServer/0", {
mode: FeatureLayer.MODE_SNAPSHOT,
id: "ServiceTest",
opacity: .4,
visible: true,
outFields:["*"]
});
legendLayers4.push({ layer: ServiceTest, title: 'Test' });

 

View solution in original post

0 Kudos
1 Reply
jaykapalczynski
Frequent Contributor

I got it....

<serverUrl url="https://xxxx.xxxx.xxxx.gov/arcgis/rest/services/Test/Test/FeatureServer/0"
matchAll="true" username="User" password="U$er"
tokenServiceUrl="https://xxxx.xxxx.xxxx.gov/arcgis/tokens/" />
urlUtils.addProxyRule({
urlPrefix: "https://xxxx.xxxx.xxxx.gov/arcgis/rest/services/Testing/Test/FeatureServer/0",
proxyUrl: "https://xxxx.xxxx.xxxx.gov/DotNet/proxy.ashx"
});
 window.ServiceTest = new FeatureLayer("https://xxxx.xxxx.xxx.gov/arcgis/rest/services/Testing/Test/FeatureServer/0", {
mode: FeatureLayer.MODE_SNAPSHOT,
id: "ServiceTest",
opacity: .4,
visible: true,
outFields:["*"]
});
legendLayers4.push({ layer: ServiceTest, title: 'Test' });

 

0 Kudos