Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 982269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:40:13+00:00 2026-05-16T04:40:13+00:00

We have a load balanced (NLB) ASP.NET web app which sends email. The servers

  • 0

We have a load balanced (NLB) ASP.NET web app which sends email.

The servers are dual homed with an external facing and internal (behind firewall) facing IP. The Mail server is behind the firewall.

We have been seing a problem where the SMTPClient class throws an exception stating it is unable to connect to the SMTP server.

The networking guys are telling us they are seeing attempts to connect to the SMTP server from the external facing IP address (which the firewall is blocking)

From my (admittedly patchy) knowledge of network enabled applications I thought that the local IP binding would be decided based on the destination, i.e. if the routing tables say the IP address can be accessed through a particular NIC than that is the IP the outbound request is generated from. Am I wrong?

looking at SmtpClient.ServicePoint I’m beginning to think that we might be and that we can (should) force an explicit binding to a particular IP?

specifically I’ve been looking at
ServicePoint.BindIPEndPointDelegate Property
from that page…

Remarks :Some load balancing techniques
require a client to use a specific
local IP address and port number,
rather than IPAddress.Any (or
IPAddress.IPv6Any for Internet
Protocol Version 6) and an ephemeral
port. Your BindIPEndPointDelegate can
satisfy this requirement.

it just seems a little odd to me that I’d need to do that but perhaps thats common in this type of environment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:40:14+00:00Added an answer on May 16, 2026 at 4:40 am

    You need to do something like this…

    public delegate IPEndPoint BindIPEndPoint(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount);
    
    private IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount) {
        if (retryCount < 3 && ddSendFrom.SelectedValue.Length > 0)
            return new IPEndPoint(IPAddress.Parse("192.168.1.100"), 0); //bind to a specific ip address on your server
        else
            return new IPEndPoint(IPAddress.Any, 0);
    }
    
    protected void btnTestMail_Click(object sender, EventArgs e) {
        MailMessage msg = new MailMessage();
        msg.Body = "Email is working!";
        msg.From = new MailAddress("me@me.com");
        msg.IsBodyHtml = false;
        msg.Subject = "Mail Test";
        msg.To.Add(new MailAddress("you@you.com"));
    
        SmtpClient client = new SmtpClient();
        client.Host = "192.168.1.1";
        client.Port = 25;
        client.EnableSsl = false;
        client.ServicePoint.BindIPEndPointDelegate = new System.Net.BindIPEndPoint(BindIPEndPointCallback);
        client.Send(msg);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At my day job we have load balanced web servers which talk to load
I have load balanced web servers My application has a function that allows the
We have a couple of web servers using load balancer. Machines are running IIS6
Assuming there are a number of load-balanced web servers in a web farm, is
We have an application that runs over load balanced server instances, and therefore is
I have inherited a load of VB6 code which has tons of individual OCX
I have a page on which I must load controls dynamically based on the
I have got some code to load an assembly and get all types, which
I have two servers running Windows 2008 Web Edition and SQL 2008 Standard Edition,
I have a big load of documents, text-files, that I want to search for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.