IP and Location information - c#

I've searched about ip & location for my website. I want to know where my visitor have entered the website. According to his location i will make some recordings, show the website with a different theme and so on.
I'm using Asp.Net, I would not use any providers or tools. I want to do it my own. How can I do it ? What shall I search ?

You'll need to use a third party service or tool to gather GeoLocation. I suggest trying out the IPInfoDB, http://www.ipinfodb.com , which is a free GeoLocation service. Once you sign up for an API key you can consume the service in C# as follows:
public static GeoLocation HostIpToPlaceName(string ip)
{
string url = "http://api.ipinfodb.com/v2/ip_query.php?key={enterAPIKeyHere}&ip={0}&timezone=false";
url = String.Format(url, ip);
var result = XDocument.Load(url);
var location = (from x in result.Descendants("Response")
select new GeoLocation
{
City = (string)x.Element("City"),
Region = (string)x.Element("RegionName"),
CountryId = (string)x.Element("CountryName")
}).First();
return location;
}
There are many services that provide GeoLocation but IPInfoDB is free and has worked well for me.
You can also gather this information on the client side using HTML5 as demonstrated at http://html5demos.com/geo . Of course if you want to use this information in your code you would somehow have to pass it to the backend.

The concept you are talking about is called Geo Location. The gist of it is there are databases that map ip addresses to ISP and ISP to physical locations. Here is the google search I used.
geo locate ip address
This page was particuarly interesting because it offered a good explication and some sources for free data.
http://www.iplocation.net/
Good Luck.

You have to use a third party service to fetch geo information about your user. I personally use https://api.iplocation.net/ that is free and without registration. It fits my need as I just need to know the country iso code.
You just have to make an http request to an api endpoint to get a json response. Happy coding !

Related

I need API URL of GMapProviders.GoogleMap

I use the gmap.net library for my WinForms application and connection through the proxy.
Here is the code:
mapCtrl.MapProvider = GMap.NET.MapProviders.GMapProviders.GoogleMap;
GMaps.Instance.Mode = AccessMode.ServerOnly;
GMap.NET.MapProviders.GMapProvider.WebProxy =
System.Net.WebRequest.GetSystemWebProxy();
GMap.NET.MapProviders.GMapProvider.WebProxy.Credentials =
System.Net.CredentialCache.DefaultCredentials;
The problem is that the information security department of my company is blocking these connections and as result, the maps tiles don't load. They ask me to give them the API URL for entering it into the white list.
Somebody knows which URL uses Gmap.net for GMapProviders.GoogleMap?
From Martin Costello's comment
Use a tool like WireShark or Fiddler on your local machine and see what URLs the application tries to access over the network.
Using Fiddler helped me.

CRM 2013 Get CRM URL via Custom Workflow

I have a requirement for getting a CRM URL via a custom workflow to use in the next step which is to send an email. The reason for this is to differentiate to users which server this email has come from (UAT/Live).
I have been trying to use HTTPContext route as advised from this site https://social.microsoft.com/Forums/en-US/31ff567d-65ea-4385-a764-68a2121ae8c0/ms-crm-2011-get-path-of-crm-server-url-in-plugin?forum=crmdevelopment but the result I get back is useless as I am I am only receiving an "/" back.
Does anyone know what to do from this point or why this may not be working?
This can't be accomplished, in a supported manner, without creating a connection to the CRM Discovery Service, which requires that you supply credentials. The organization service, available in the workflow does not have a method for discovering the organization's URL.
You have two options:
1) Pass it to the workflow as a parameter using the InputParameter code attribute on your CodeActivity.
2) Create (if you don't already have one) a configuration entity to store the URL and retrieve it in your code.
If you don't really need the URL (i.e., you are not creating a link) then you could just query the Organization entity for the Name attribute. That will give you the Organization's name - which would be the only unique part of the URL. This would allow you to indicate to the user if the Email was coming from UAT or Prod.
I ended up coming up with a solution by using the environment.machinename to pull through the server name. From there i could determine which production server the workflow had been run through and passed a string containing, dev, uat or live to the output to use in my activity emails.
Be aware i had to register the workflow without it being in sandbox mode. Hope this helps somebody in the future.
This was an extremely old question but I came across it while attempting to do something similar.
I found that there is a RetrieveCurrentOrganizationRequest request which was introduced in v9. This will work in sandboxed plugins.
You can use this to retrieve the endpoint urls like so
var currentOrg = base.OrgService.Execute(
new RetrieveCurrentOrganizationRequest()
) as RetrieveCurrentOrganizationResponse;
var url = currentOrg.Detail.Endpoints
.Where(e => e.Key == EndpointType.WebApplication)
.FirstOrDefault()
.Value;
More information here: RetrieveCurrentOrganizationRequest
When I used it, I found that there are 3 available URLs in the Endpoints collection:
Web Application
Organization Data Service
Organization Service
Relevant to CRM 2013 (which the OP was using at the time), there is also the RetrieveOrganizationRequest class which does the same as above; however you have to specify the Organization (and some other information)

Retrieve Attendee Address details from Eventbrite v3 API

I'm trying to retrieve address information and home phone of attendees though the endpoint "https://www.eventbriteapi.com/v3/events/{eventId}/attendees/?token={token}".
But in the response i did not find the address information of any attendee though i had added the address fields. In response, i found a profile key which gave me the "cell_phone" but still no luck with the home phone or the address details.
The address details i'm taking about is the country, address, city, state, zipcode. i'm not able to find the same within the documents. i'm using the new version of api, the old version had event_list_attendees method which listed all the information i needed.
I would want the same response which "event_list_attendees" gave. Is there any method in the new API which would do the same.
Am i missing some step or the v3 API doesn't return these field ?
Kindly help.
Well i found that this is a bug with the new version of API. we have raised a ticket with the eventbrite team and this would be taken care of shortly.
I've had the same issue, they say they are aware and are updating the API - its currently only in preview!
I know this is quite old, but just wanted to let you know that the issue has been resolved and you can now access all Attendee address information.

cloudfront private time limited url

I have a client that wants to sell tutorial videos online. I already got previews of his tutorials streaming from CF (This is public). Now I want to use the c# sdk to generate private, time limited URLs to allow customers who purchased the tutorials to download them for a limited time period.
Once the payment has been confirmed, I want to generate a URL and send it to the client via email.
Does CF/.NET SDK support this?
Can someone point me at a sample. I have searched Google, and got a little information overload. Different examples from different versions of sdk/management console. Please help me make sense of it all :)
If you look at the class Amazon.CloudFront.AmazonCloudFrontUrlSigner that has helper methods for creating presigned URL to private distributions. For example this code snippet creates a url that is valid for one day.
var url = AmazonCloudFrontUrlSigner.GetCannedSignedURL(AmazonCloudFrontUrlSigner.Protocol.http, domainName, cloudFrontPrivateKey, file, cloudFrontKeyPairID, DateTime.Now.AddDays(1));
There are other utility methods in that class for adding more specific access rules.
Note this class was added in version 1.5.2.0 of the SDK which came out in late Augest
Yes Amazon S3 as well as CloudFront both support preSignedUrl access. If you want to faster content delivery the you should use CloudFront. Mr. Norm Johanson saying correct. To generate signed url you will need of Public-Private key pair. You can user your own key pair and lets associate with you account of Amazon S3 or you can also generate it at amazon s3 account and download to generate presigned url
You can use the GUI or code in S3SignURL to sign your URL
https://github.com/DigitalBodyGuard/S3SignURL
You can't do this with CloudFront (CF), but you can do this directly with S3. You simply call the GetPreSignedURL function to generate a time-limited URL to a specific (private) S3 item. This approach is covered in a tutorial here.
The simplest code sample is this:
AmazonS3 client;
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest();
request.WithBucketName(bucketName);
request.WithKey(objectKey);
request.Verb = HttpVerb.GET; // Default.
request.WithExpires(DateTime.Now.AddMinutes(5));
string url = client.GetPreSignedURL(request);

How to convert IP Address to GeoLocation using ASP.Net or Razor Systax or Bing Map?

I build the ASP.Net (.cshtml) site, and I need to get current location of user to show in Bing Map. How can I do this feature?
MaxMind offers a IP geolocation library and API, see: http://www.maxmind.com/app/api
They offer a number of Windows APIs, including C#. see: http://www.maxmind.com/app/windows
(Disclaimer: not affiliated, just a happy customer. I've not used the Windows APIs).
I wouldn't ever try to implement this myself. Using HTML5 you can actually get the best location available for the computer/device trying to view the page. One of the fallbacks that browsers use when there isn't a GPS device attached it to lookup the location of the IP address. This only works in HTML5 browsers but it's a very fast and cheap solution.
Javascript:
navigator.geolocation.getCurrentPosition(show_map);
function show_map(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
}
If you want more details I find this site really useful.
http://diveintohtml5.ep.io/geolocation.html
did you checked nerddinner tutorial, chapter 11: Integration with an ajax map? http://nerddinnerbook.s3.amazonaws.com/Part11.htm
Nerddinner uses js files -included in the example - plus a location request - included in the example too - .
to download files http://nerddinner.codeplex.com/SourceControl/list/changesets if you want razorĀ“s examples, otherwise http://nerddinner.codeplex.com/
Full tutorial starts here http://nerddinnerbook.s3.amazonaws.com/Intro.htm
brgds.

Categories