C# - How To Get User Location Using User IP Address
Aug 5, 2010Possible Duplicate:
How to get visitor location ( country, state and city ) using ASP.NET
How get user location using user IP address using asp.net?
Possible Duplicate:
How to get visitor location ( country, state and city ) using ASP.NET
How get user location using user IP address using asp.net?
I have site ( ASP.NET, C# ) and I need to automatic show start page based on user location. Can I get name of user city if I have IP address of user ?
View 5 RepliesFollowing is my code when user enters hospital name and city, he will be navigated to this page to show location on map. Now I want to get user current location and draw the route between current location and destination. Is there any way to integrate to geocoding and geolocation?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
html, body, #map-canvas
[Code] ....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[Code] ....
currently I am working on an activities management system, in this application I want to give facility to show the visitor location of this site. I am using c# and asp.net so how we should start implementation
View 3 Replieshow should i find the user country when the open the website ?
View 2 RepliesI am creating a web site in visual studio 2008.
I want to allow the current user to log in but log off any other person logged in under the same username as the current user. (just like like Y!M does when you log in from a different location: It signs you out from the initial location) For managing log in and sign up i am using visual studio createuserwizard and log in cotrol.
Can anyone explain how to make unique login in asp.net
<b>Problem:</b> If user is logged at a client machine and tries to login from other client machine at the same time, then he should be prompted that "You are already logged in, Do you want to continue?" on continue user should be logged out from other machine and logged in to current machine.
I have develop an ASP.NET website and I want store some uploaded files in a shared location in some different server. On that server one user has the access.
how it is possible to get the access of the shared location on the server with my Web site?
Let me tell you what I need to implement on my company .NET application and I will be more than glad to hear your advise how to do it:
For every user loged-in to the company website, We want to know on which page he is right now. It means, If user X is now on page "1.html", I need to save this information somewhere. If user X after 30-60 seconds going to page "2.html" I want to update it fast where he is now surfing. It means I want to be able to tell at REAL TIME, on each page, Which users are right now observing the page. This is the problem, now I'm looking for the right solution.
If some day my company website will have 400,000 user log-in at the same time, I am going to save to every one of them where he is surfing right now. Maybe I exaggerated, but we do have 45,000 users at the same time on the company web site and the number is growing. I think big so the solution for this problem will be good for a lot of users.
So, my data object for every user should keep this information somewhere:
1. User code (User Number).
2. Which page user is now observing (Page Number).
This object is going to update every 30-60 seconds by using AJAX, so it should be updated fast. It is a lot of reading/writing data. If a user want to see which other users are now on the same page as he his, he will be able to see it, just by going through the whole array of objects.
I don't need this information to be saved in DB, because it doesn't mean anything. It is temporary and changing A LOT. So, I think the right place to do it is using RAM at the the company server, using the Caching Data option. What do you think? Am I wrong?
If I am going to have a data table with lots of records and every record is going to be update every 30-60 seconds. Where should I save all this table data? I am using SQL Server 2008 to save important data as needed, but this data is not important to save, just need to use it for my purpose. Where should I save this data? I think saving it in DB is a bad idea, because of the dynamic update of records every few seconds. I am thinking about 100,000 users who update this table every few seconds. It probably going to kill my DB, so DB is not an option.
What is the right way to implement this kind of thing?
You may think of it like every page is "a chat room" and I want to know who enter now the room (the page), it doesn't have to be completely accurate in time, but approximately.
I have a very simplistic user control that looks like this:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="wfWindow.ascx.cs" Inherits="webfanatix.co.za.wfWindow" %>
<div>Just a test...[x]</div>
with this code behind:
[ParseChildren(false)]
[PersistChildren(true)]
public partial class wfWindow : System.Web.UI.UserControl
{
protected override void Render(HtmlTextWriter writer)
{
RenderChildren(writer);
}
}
And the usage thereof looks like this:
<wf:wfWindow runat="server">This content should go where [x] is.</wf:wfWindow>
I'm no ASP.NET pro, so how do I get the content to render exactly where the [x] appears in my user control?
RenderChildren is rendering my content, but it is only appended to the end of the UserControl output. I need it to go and sit right where [x] marks the spot.
I want to capture user ip address but some reason i am getting different values:
method 1:
Dim strHostName As String = System.Net.Dns.GetHostName()
Dim clientIPAddress As String = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString()
method 2:
Dim k As String = Request.ServerVariables("remote_addr")
I am trying to fetch the IP address using this:-
protected void Page_Load(object sender, EventArgs e)
{
string ClientIP;
ClientIP = HttpContext.Current.Request.UserHostAddress;
Label1.Text = ClientIP;
}
This code outputs 127.0.0.1.
And the code below displays nothing!
string ClientIP;
ClientIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Label1.Text = ClientIP;
How do I fetch the IP address? The REAL IP address of a user?
[EDIT]
I don't want EXACT location BTW. I need to know the country and then redirect the user to a webpage accordingly.
Does anyone know how this is possible? I can retrieve the file, but I cannot figure out or find anywhere online how to prompt the user where he/she wants to download the file to.
View 2 RepliesI want to create an asp.net application which allow user to specify text file path and create a text file on the specified location by doing some processing from the sql server database.for specifying path of the txt file i am using setting
.xmlsetting.xml
<TextFilePath> "D:Text" <TextFilePath> //as specified by the user.
The code is working fine if it is not published Once the application is uploaded on the server(published) and run under the virtual directory.
I used Ajax collapsible extenders (1 to 9) with formviews in each of them on a web form.
They are all collapsed by default. If the user enters data in collapsible 5 formview and submits data, the page refreshes back to the top of the page (where the collapsible 1 is positioned). I would like the focus to stay in the region the user is working (even after insert/submit operations). How can I do this.
I used following methods
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]
Request.ServerVariables["REMOTE_HOST"]
Request.UserHostAddress
Request.UserHostName
All the above are returning "127.0.0.1", not the actual IP.
The below one returns null.
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
Below one always returns where the application is hosted/running, not the client's IP address.
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
which property should be used to get the ip address of a connected useruse property
View 3 Replieswe have some files in our web app which saved in database.
how user can download files from our web site which exists in database (and not physically saved) ?
I want to add a new rule in my web.config file programmatically,
ex: I have a textbox to add location path I have a combobox (with items admin and user) to add roles. ex: user input location path = textbox roles = combobox (items admin and user) the save button, when click the save button the results go to the web config :
<location path="Report/ManageReport.aspx">
<system.web>
<authorization>
<allow roles="ADMIN" />
<deny users="*" />
</authorization>
</system.web>
</location>
So far my code as below: but I was confused to apply its
protected void AddRoleRule(string location, string selectedrole)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(Server.MapPath("~/Web.config"));
XmlDocument xDoc = new XmlDocument();
xDoc.Load(config.FilePath);
//if the rule exists update the rule
[Code] .....
i'm creating a asp.net web application in which i need to select source file using browse button to select the Source location from where the files has to be copied from and destination file using browse button to select the destination location where the files has to be copied to .So pls tell me what should be the code for browse button to browse a folder for source and destination and copy the source folder files to destination folder(i want to copy only text and excel files from source to destination folder) and i want user to see the progress how files are copying from source to destination and error also if there is any error in copying.
View 1 RepliesI have a data list on my page which shows a clients company, address and contact info. This information is stored in a sql database table. one of the columns is email address
Also on the page is a button and textbox set to multimode where the logged on client can send a message.
In the the button click event I want to send the message but capture the email address from the "Email" column and add this to the from part of the mail message as below
[Code]....
I just want to get the email address this way or get it from the membership system which ever is better.
In a controller action of a CastleMVC application, how can I get the user's IP Address?
I think in asp.net mvc it would be Request.ServerVariables["REMOTE_ADDR"], but I can't find an equivalent in Castle.
(I am aware of potential proxy issue's etc, the address that is reported in the request is fine)
This is the current architechture and this is the question I have: Current architechture: We have an intranet application. No one accesses from outside the firewall. It's pretty simple architechture. We have a webservice and WebUI. The Web UI calls the webmethods of the webservice. So far so good. It works fine. Both webservice and WebUI runs under the context of the same service account (non human user account) that we created. The security is a role based security. If a user is a specific AD group, he can access with web UI. On the webui and webservice we have "Integrated windows authentication".
Code:
<authorization>
<allow roles="MycompanyApr-DataWriters"/>
</authorization>
So all the users and the service account that runs this webservice are in this AD group Apr-DataWriters. When a user launches this webUI, I want to find out either his box number of IP address of this box and datetime stamp. How can i get that information.
I have tried fetching the ip from below mentioned methods
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] &
Request.UserHostAddress & Request.ServerVariables["REMOTE_ADDR"]