简体   繁体   中英

Unable to get user location when hosting in IIS

I am creating a website in asp.net version 4.0. I am able to get the device location using GeoCoordinateWatcher class when i host it using local asp.net development server. But wen i host it in IIS, I get GeoCoordinateWatcher.permission as denied and GeoCoordinateWatcher.status as disabled. Please help.

UPDATE

int count = 0; 
coodi: gcw.TryStart(false, TimeSpan.FromMilliseconds(1000)); 
GeoCoordinate cood; 
var y = gcw.Status; 
if (y != GeoPositionStatus.Ready && count<6) { 
    count++; goto coodi; 
} 
cood = gcw.Position.Location; 
if (cood.IsUnknown != true) { 
    lat = cood.Latitude; 
    lon = cood.Longitude; 
    count = 0; 
} else { 
    lat = lon = -1; 
}

Could anyone help me to request the user to allow me to use his location as any site requests like, "This site wants to use your location? Allow or deny?".

The API you're looking for is the HTML5 Geolocation API: http://www.w3schools.com/html/html5_geolocation.asp

You can't use local APIs like System.Device.Location from serverside script to get the remote client's location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM