473,657 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to use Request.ServerV ariables("remot e_addr")

I don't seem to understand how to use the value:
Request.ServerV ariables("remot e_addr")

I am trying to pass the ip address of a sending web client in the body of an
email message.

When I compile the following code I get the this error message:

Error 1 'System.Web.Htt pRequest.Server Variables' is a 'property' but is used
like a 'method' D:\Projects\sam ple\comments.as px.cs 38 78
D:\Projects\sam ple\

For all I know, there may be more errors than just haven't shown their head
yet.
Can somebody tell me how to pass the value to my message?

//*************** *************** *************** ********
protected void contactUS_Click (object sender, EventArgs e)

{

//Things to Do:

// Validate form fields:

// Name field should be letters and spaces only. Can't be blank or only
spaces.

// Phone field may have () - spaces and digits

// email address must be properly formatted.

// Eventually I would like to add a check for domain validity

// After edits I need to create the message

MailMessage msg = new MailMessage();

MailAddress _from = new MailAddress(Fin dControl("email ").ToString ());

MailAddress _sender = new MailAddress("in **@morristwpgop .org");

msg.From = _from;

msg.Sender = _sender;

msg.Subject = "Feedback from Comments Form";

StringBuilder sbuilder = new StringBuilder() ;

//Build string for message body

sbuilder.Append Line("Sender's IP Address: " +
Response.Write( Request.ServerV ariables("remot e_addr")));

sbuilder.Append Line("Name: " + FindControl("na me").ToString() );

sbuilder.Append Line("Phone: " + FindControl("ph one").ToString( ));

sbuilder.Append Line("Email: " + FindControl("em ail").ToString( ));

sbuilder.Append Line("Message: " + FindControl("me ssage").ToStrin g());

//assign string value to message body

msg.Body = sbuilder.ToStri ng();

//create the smtp client

SmtpClient _smtp = new SmtpClient();

_smtp.DeliveryM ethod = SmtpDeliveryMet hod.Network;

_smtp.Host = "mrelay.perfora .net";

_smtp.Port = 25;

_smtp.Send(msg) ;
}

//*************** *************** *************** *****
Aug 16 '08 #1
2 4120
re:
!I am trying to pass the ip address of a sending web client in the body of an email message

The "sending web client" is your web server in that case.

re:
!Can somebody tell me how to pass the value to my message?

You'd have to capture the IP when the web client arrives at a preliminary page
which then redirects to your web mail form, passing the IP value to your email form.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Henry Stock" <he***@henry-stock.comwrote in message news:eT******** ******@TK2MSFTN GP06.phx.gbl...
>I don't seem to understand how to use the value:
Request.ServerV ariables("remot e_addr")

I am trying to pass the ip address of a sending web client in the body of an email message.

When I compile the following code I get the this error message:

Error 1 'System.Web.Htt pRequest.Server Variables' is a 'property' but is used like a 'method'
D:\Projects\sam ple\comments.as px.cs 38 78 D:\Projects\sam ple\

For all I know, there may be more errors than just haven't shown their head yet.
Can somebody tell me how to pass the value to my message?

//*************** *************** *************** ********
protected void contactUS_Click (object sender, EventArgs e)

{

//Things to Do:

// Validate form fields:

// Name field should be letters and spaces only. Can't be blank or only spaces.

// Phone field may have () - spaces and digits

// email address must be properly formatted.

// Eventually I would like to add a check for domain validity

// After edits I need to create the message

MailMessage msg = new MailMessage();

MailAddress _from = new MailAddress(Fin dControl("email ").ToString ());

MailAddress _sender = new MailAddress("in **@morristwpgop .org");

msg.From = _from;

msg.Sender = _sender;

msg.Subject = "Feedback from Comments Form";

StringBuilder sbuilder = new StringBuilder() ;

//Build string for message body

sbuilder.Append Line("Sender's IP Address: " + Response.Write( Request.ServerV ariables("remot e_addr")));

sbuilder.Append Line("Name: " + FindControl("na me").ToString() );

sbuilder.Append Line("Phone: " + FindControl("ph one").ToString( ));

sbuilder.Append Line("Email: " + FindControl("em ail").ToString( ));

sbuilder.Append Line("Message: " + FindControl("me ssage").ToStrin g());

//assign string value to message body

msg.Body = sbuilder.ToStri ng();

//create the smtp client

SmtpClient _smtp = new SmtpClient();

_smtp.DeliveryM ethod = SmtpDeliveryMet hod.Network;

_smtp.Host = "mrelay.perfora .net";

_smtp.Port = 25;

_smtp.Send(msg) ;
}

//*************** *************** *************** *****


Aug 16 '08 #2


"Henry Stock" <he***@henry-stock.comwrote in message
news:eT******** ******@TK2MSFTN GP06.phx.gbl...
I don't seem to understand how to use the value:
Request.ServerV ariables("remot e_addr")

I am trying to pass the ip address of a sending web client in the body of
an email message.

When I compile the following code I get the this error message:

Error 1 'System.Web.Htt pRequest.Server Variables' is a 'property' but is
used like a 'method' D:\Projects\sam ple\comments.as px.cs 38 78
D:\Projects\sam ple\

For all I know, there may be more errors than just haven't shown their
head yet.
Can somebody tell me how to pass the value to my message?

//*************** *************** *************** ********
protected void contactUS_Click (object sender, EventArgs e)

{

//Things to Do:

// Validate form fields:

// Name field should be letters and spaces only. Can't be blank or only
spaces.

// Phone field may have () - spaces and digits

// email address must be properly formatted.

// Eventually I would like to add a check for domain validity

// After edits I need to create the message

MailMessage msg = new MailMessage();

MailAddress _from = new MailAddress(Fin dControl("email ").ToString ());

MailAddress _sender = new MailAddress("in **@morristwpgop .org");

msg.From = _from;

msg.Sender = _sender;

msg.Subject = "Feedback from Comments Form";

StringBuilder sbuilder = new StringBuilder() ;

//Build string for message body

sbuilder.Append Line("Sender's IP Address: " +
Response.Write( Request.ServerV ariables("remot e_addr")));

sbuilder.Append Line("Name: " + FindControl("na me").ToString() );

sbuilder.Append Line("Phone: " + FindControl("ph one").ToString( ));

sbuilder.Append Line("Email: " + FindControl("em ail").ToString( ));

sbuilder.Append Line("Message: " + FindControl("me ssage").ToStrin g());

//assign string value to message body

msg.Body = sbuilder.ToStri ng();

//create the smtp client

SmtpClient _smtp = new SmtpClient();

_smtp.DeliveryM ethod = SmtpDeliveryMet hod.Network;

_smtp.Host = "mrelay.perfora .net";

_smtp.Port = 25;

_smtp.Send(msg) ;
}

//*************** *************** *************** *****

In C# you need [] rather than ():
Request.ServerV ariables["remote_add r"]

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name

Aug 16 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1837
by: Vilmar | last post by:
Hi, Can Request.ServerVariables("REMOTE_ADDR") fail and catch the address of my default gateway in my local network?? What should I do? Sometimes brings 192.168.0.1(the address of my default gateway) instead the remode IP address: 200.200.15.2, 64.100.2.1, etc.... Thanks, --
9
2429
by: Luc Dal | last post by:
Hello, I've serious problem using ASP under WindowsXP sp2. I get the following reply (sorry it's in french) Erreur de compilation Microsoft VBScript error '800a0401' Fin d'instruction attendue /iisHelp/common/500-100.asp, line 11
3
1474
by: Charles Stanley | last post by:
Hi all, I'm new to C#, and have two pretty simple questions: I have a class, in a .cs file by itself. I need to make use of the sole function in this class in another .cs file. Here's the code, filename bannertrack.cs First question - the function "LogImpr" users ServerVariables + "')"; The compiler tells me that this is not included in the namespace. ??
3
11689
by: hn | last post by:
I would like to get the visitor's ip address. Which one is the appropriate one to use: Request.ServerVariables("REMOTE_ADDR") or Request.UserHostAddress? Thanks in advance.
5
12291
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. On Beta1, I am able to execute a particular page with no problem, that page opens up in the comes up just fine. On Win2kdev1, when I go to execute the same page, it opens a file download dialog and asks me whether I want to open or save the...
6
4868
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
1
1551
by: mcarten | last post by:
I'm getting the dreaded "nullreferenceexception" error with this code. In an ASP application it works fine. In VB Express 2005 it does not. These are my imports .... Imports System Imports System.Net Imports System.Net.IPAddress
10
2298
by: Breana | last post by:
Ok i found this a while back and i am trying to mod it so it works but it keeps not updating the users online and kills my other code? Well i got it working but it dont update when i login? It says 14 guest now, and i am logged in so it sould ream me as member..... And how do i make a cron job, the tutorial says it lowrs site badwith and it runs better updating records?
5
7359
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : $http_ref= $HTTP_REFERER; $prog = $_COOKIE;
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.