<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk" -->

---
title: ASP.NET load balancing and ASP.NET state server...
description: A walkthrough of setting up a load-balanced ASP.NET environment across two servers using the ASP.NET State Service for centralized session management. Covers...
canonical: https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: ASP.NET load balancing and ASP.NET state server (aspnet_state) | daily.dev
og:description: A walkthrough of setting up a load-balanced ASP.NET environment across two servers using the ASP.NET State Service for centralized session management. Covers...
og:url: https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk
og:image: https://api.daily.dev/og/posts/5BWGWxEsk.png
og:image:alt: ASP.NET load balancing and ASP.NET state server (aspnet_state)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ASP.NET load balancing and ASP.NET state server (aspnet_state)

**[Maarten Balliauw](https://daily.dev/sources/maartenballiauw)** · 3 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of setting up a load-balanced ASP.NET environment across two servers using the ASP.NET State Service for centralized session management. Covers enabling remote connections to the state service via registry edits, configuring sessionState in Web.config with stateConnectionString, and a gotcha where both servers returned identical but inconsistent session data due to the machineKey element needing to be explicitly synchronized across servers. Also flags the state server itself as a new single point of failure and links to a follow-up post on session state partitioning.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.maartenballiauw.be/posts/2007-11-22-aspnet-load-balancing-and-aspnet-state-server-aspnet_state>

## Questions this post answers

### Why do two load-balanced ASP.NET servers show different session data even though the session ID cookie is the same?

The session data differs because each server has its own machineKey values used to encrypt and validate session data, even though sessionState mode is set to StateServer with a shared connection string. Explicitly setting matching validationKey and decryptionKey values in the machineKey element of Web.config on every server resolves the mismatch.

_When debugging shared session state across servers, daily.dev surfaces practical ASP.NET load-balancing fixes like this one._

### How do I configure the ASP.NET State Service to accept connections from other servers in a load-balanced setup?

By default the ASP.NET State Service only listens locally, so remote servers cannot connect. Enable remote connections by editing the registry key HKLM\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnections, optionally change the listening port via the Port key (default 42424), then restart the service. Make sure port 42424 stays closed to the public Internet.

_Teams wiring up shared session state across servers can find setup gotchas like this through daily.dev._

## Similar posts on daily.dev

- [5 Mistakes Teams Make When Scaling .NET Applications](https://daily.dev/posts/5-mistakes-teams-make-when-scaling-net-applications-jeilk21xw) · Telerik · 5 upvotes · 0 comments
- [State Management in Blazor: Complete Guide to Building Scalable Apps](https://daily.dev/posts/state-management-in-blazor-complete-guide-to-building-scalable-apps-mqdzaor6r) · Syncfusion · 1 upvotes · 0 comments
- [Real-Time at Last: SSE and SignalR in ASP.NET Core](https://daily.dev/posts/real-time-at-last-sse-and-signalr-in-asp-net-core-hfyl1qquh) · We Are .NET · 0 upvotes · 0 comments
- [Server-Sent Events in ASP.NET Core and .NET 10](https://daily.dev/posts/server-sent-events-in-asp-net-core-and-net-10-rqln4wisb) · Milan Jovanović · 25 upvotes · 0 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"ASP.NET load balancing and ASP.NET state server (aspnet_state)","url":"https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk"},"datePublished":"2026-10-04T13:06:10.256Z","dateModified":"2026-10-04T13:13:51.923Z","description":"A walkthrough of setting up a load-balanced ASP.NET environment across two servers using the ASP.NET State Service for centralized session management. Covers...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/afc740074e3dd668347155910a12b8b8?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/afc740074e3dd668347155910a12b8b8?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Maarten Balliauw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Maarten Balliauw","logo":"https://media.daily.dev/image/upload/s--rOTg3VYO--/f_auto,q_auto/v1791119043/logos/maartenballiauw?_a=BAMAMicg0","url":"https://daily.dev/sources/maartenballiauw"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,c#","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Maarten Balliauw","item":"https://daily.dev/sources/maartenballiauw"},{"@type":"ListItem","position":3,"name":"ASP.NET load balancing and ASP.NET state server (aspnet_state)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/asp-net-load-balancing-and-asp-net-state-server-aspnet-state--5bwgwxesk#faq","mainEntity":[{"@type":"Question","name":"Why do two load-balanced ASP.NET servers show different session data even though the session ID cookie is the same?","acceptedAnswer":{"@type":"Answer","text":"The session data differs because each server has its own machineKey values used to encrypt and validate session data, even though sessionState mode is set to StateServer with a shared connection string. Explicitly setting matching validationKey and decryptionKey values in the machineKey element of Web.config on every server resolves the mismatch. When debugging shared session state across servers, daily.dev surfaces practical ASP.NET load-balancing fixes like this one."}},{"@type":"Question","name":"How do I configure the ASP.NET State Service to accept connections from other servers in a load-balanced setup?","acceptedAnswer":{"@type":"Answer","text":"By default the ASP.NET State Service only listens locally, so remote servers cannot connect. Enable remote connections by editing the registry key HKLM\\SYSTEM\\CurrentControlSet\\Services\\aspnet_state\\Parameters\\AllowRemoteConnections, optionally change the listening port via the Port key (default 42424), then restart the service. Make sure port 42424 stays closed to the public Internet. Teams wiring up shared session state across servers can find setup gotchas like this through daily.dev."}}]}
```

