Wednesday, July 20, 2011

Simple FTP using Batch File

For FTP, I have used two batch files.
File1- example.bat

Create example.bat file with the following contents:

open <ip address>
<ftpUserName>
<ftpPassword>
bin
lcd "<path of local folder where the file is present>"
cd /
prompt off
put filename.extension
quit

File2- Sendexample.bat

Create Sendexample.bat file with the following contents:

ftp -s:example.bat

Thats It...Enjoy

Also if you need to ftp multiple files use "mput" option instead of "put".

Sunday, July 3, 2011

Capture IP Address using Asp.Net

The code given below gives you the IP address of the User Accessing the site.

1) HttpContext.Current.Request.UserHostAddress;

OR

2) HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

To get the IP Address of the machine and not the proxy use the following code:

1) HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];