I am looking for some help with my first C# web application connection to pull some data out.
I have the all the sample parameters to make the call via the web based query page, I specified all the values needed, once I press Query (Get), I get the data and the fields/properties that I was looking for.
Now I want to translate all this to a C# web page to integrate in a web based application.
I want to leverage the data in there, but would like some help on a sample example that shows this done via C# web application.
Thanks,
when you say query get page do you mean something that looks like this?
When you do the query are you getting something below it like this:
(Indicating you have selected:
to HTML?)
Yes that is correct on all that you posted.
so how do I take all this and apply to a c# web application that makes the call to esri and gets the data returned and displayed to the screen/user
Are you already familiar with the .Net SDK? https://pro.arcgis.com/en/pro-app/latest/sdk/index.html
When I did my first integration, I didn't know a lot about the .Net SDK, but I did see that each FeatureService can be queried restfully via query string, and return a json slice of data you can then serialize and use.
When I did that, I was actually embedding an ArcGIS map/webapp in an IFrame in the website we had setup, but its my understanding you ought to be able to render the maps as resources in a page just like any other source in C#. When I recently updated my Visual Studio instance I noticed there were some out of the box functionality just for ArcGIS . I was able to configure a search panel that would query two different arc GIS instances by address for example and return related records I could look at to create golden records for one of our department. (Golden record meaning it would have external agency and a snapshot of internal data so we could see who had what data, and whether it needed updating)
Some of the project templates may have some of what you need baked in enough that you can then make the changes you need.
It might be useful to look at the SDK and some of the extensions to see if any of them help expedite what you are building. I wish I could suggest a specific template type, but I haven't used them in several years, they may have changed.
Thanks for your reply and the information.
My goal is to leverage a web application I've built in C# and currently in production. Some users are hoping I could pull some 'data' and 'information' from the GIS world and import it into the web application i've made.
I don't believe there is a need to embed a map or iframe with the details as of now. The focus I'm being asked is get the data using the REST calls via GET into the C# web application.
Any more insight would be greatly appreciated.
Then you ought to be able to make asynchronous calls to the service to get data.
+
The only hang up you might run into is if any of those services require some kind of token or authentication to be able to fetch the data. I was able to build a system that hit rest end points in a local Enterprise Setup, and a State Enterprise or AGOL one as well, collect the data and bring it into one database for development and use from that as a data source. (You may not need to persist data from external GIS systems to do what you need though, so that might simplify it for you a lot.)
For that I focused on each rest layer's fields, made sure I had columns for each of them, and could create the query on the fly to then store into a Database like Microsoft SQL Server. If the data in the services is public and available via guest access the key things to know are how to query for specific things (where clause with field names and the right operators used), and outfields (can be the asterisk * wildcard character or a defined list). C# is then able to bring that json in, and then you can DeSerialize the JSON into objects the C# can use as you desire.
So if I were to summarize the key things to know:
Those are the first things that come to my mind. Feel free to ask more questions in the future if you bump into anything.
Thanks for your reply.
I will admit to this still being a fact finding mission and admit to have very little exposure to this GIS world from back ends perspective.
Currently my application is an isolated C# web application that interacts with an SQL database. Majority of the data the application uses is a 'duplicate' of the data with our GIS system.
We have manual process where our staff is taking the data from the GIS system and adding/updating into the isolated web application (I've built).
I am exploring ways to avoid this manual and duplication of data.
Even if the application I build update is able to fetch all the data from GIS and port into the table and columns within SQL then I'm many steps ahead.
As mentioned in the initial question post, I know the columns and data I want to retrieve and its there based on the web query sample I did.
The big question is how do I implement in C#, was hoping to find some samples that do the sort of thing I am looking for.
With the environment being all local (I think) permissions and security 'shouldn't' be an issue, but I guess I won't know I until something is mocked up and sample data is query via C#.
So is there anything available from a resource perspective that mimics C# making the appropriate calls and bringing in that json in, and then DeSerialize the JSON into objects the C#.
From there I think I would be ok to continue on.
Again, I appreciate your reply and support.
Unfortunately I don't have a good C# example of this anymore. I don't have access to the source.
However, what I recall doing did not connect to any special arcgis endpoints, just found the FeatureServer/{id} that i needed, and then made query calls over HTTPS with a valid token setup for the app to use.
It works like any other Restful Web API in that way
here's one example on MS that might be close: (note depending on if you are in .NetFramework, .NetCore, or .NetStandard you might need to use a different namespace to serialize from JSon. The old standard was Newtonsoft.Json, but I think it was replaced in newer .Net Builds with System.Text.Json
This SO article shows how you might use Attributes to use the correct JSON name for a property, but use a cleaner one in your C# for the code to use (THe example of "meals" vs "Meals" is on point)
https://stackoverflow.com/questions/71627453/deserialise-json-data-from-external-api-and-return-a-le...
There is a lot you can do when calling an External API in C#, so if this is new to you, I'd suggest looking up a tutorial on Youtube, or perhaps from one of the C# Teachers that use Youtube, (Like Nick Chapsas or Tim Corey) some of them have courses that can teach you what you can do on the C# side. Tim Corey has a pretty solid Mastering C# series that covers way beyond what your question is though.