c# - How to get Bing Map Session Key from code behind -
to cut down billable transaction in web form asp.net project, decided test it.
i have come across next illustration on msdn session key.
map.credentialsprovider.getcredentials( function(c) dim sessionkey string = c.applicationid 'generate request url bing maps rest services. 'use session key in request bing maps key homecoming 0 end function) my code example
private string geocodeaddress(string address) { string results = ""; string key = "bing maps key"; geocoderequest geocoderequest = new geocoderequest(); // set credentials using valid bing maps key geocoderequest.credentials = new geocodeservice.credentials(); geocoderequest.credentials.applicationid = key; // set total address query geocoderequest.query = address; // set options homecoming high confidence results confidencefilter[] filters = new confidencefilter[1]; filters[0] = new confidencefilter(); filters[0].minimumconfidence = geocodeservice.confidence.high; // add together filters options geocodeoptions geocodeoptions = new geocodeoptions(); geocodeoptions.filters = filters; geocoderequest.options = geocodeoptions; // create geocode request geocodeserviceclient geocodeservice = new geocodeserviceclient(); geocoderesponse geocoderesponse = geocodeservice.geocode(geocoderequest); if (geocoderesponse.results.length > 0) results = string.format("latitude: {0}\nlongitude: {1}", geocoderesponse.results[0].locations[0].latitude, geocoderesponse.results[0].locations[0].longitude); else results = "no results found"; homecoming results; }
after debugging it, can't see difference b/w (application id / session key) , bing api key. how can sessionkey in above example?
the session key can used on same page interactive map. passing session key between pages not allowed. assuming have ajax button or processing code on server , returning same page map, alright.
the first bit of code looks trying generate session key in .net. possible if using silverlight or wpf. i'll assume not using bing maps wpf command on server that's against terms of use. if using silverlight, there no need pass key server side.
so lets assuming generate key in javascript bing maps v7 command , pass ajax button handler on server. if case it's alright.
in code looks using old legacy soap services not recommended. in fact stopped recommending them 4 or 5 years ago. documentation taken offline couple of years ago. should using bing maps rest services faster, more accurate , has more features. can find documentation on how utilize them in .net here: http://msdn.microsoft.com/en-us/library/jj819168.aspx
also, here tips on using rest services: http://blogs.bing.com/maps/2013/02/14/bing-maps-rest-service-tips-tricks/
applicationid , session key same thing. soap services old used have different name.
you won't see differences in reports right away. can take week reports sync across servers/data centers it's low priority job massive amounts of data.
if application has decent traffic end lot more non-billable transactions billable transactions cause business relationship flagged , investigated , perchance blocked.
what should doing geocoding addresses ahead of time , storing coordinates. how applications handle type of scenario. time should need geocode on fly if have search box user input, else should geocoded ahead of time performance.
c# asp.net map bing-maps bing-api
No comments:
Post a Comment