ASP.NET DropDownValue not saved on single server in webfarm

I have a problem with what is DropDownListlosing SelectedValueafter PostBackon the server alone on the web farm. On other servers, everything works correctly.

All servers are on the same version of the code with the same service packs and all applicable updates. The code also works correctly when I start my local machine (but point to the production database).

I thought that ViewState might be a problem, but I confirmed that web.config, page aspxand code are the same for all machines.

Convert.ToInt32()I received an error while trying Input string was not in a correct format..

I added Trace.Writeto find out that the value DropDownListis nullonly on this particular server.

Code snippet

protected void Page_Load(object sender, System.EventArgs e)
{
    if (!Page.IsPostBack)
    {
        LoadClientDropDown();
    }
}

protected void LoadClientDropDown()
{
    //load the drop down ddlClients from data
}

protected void btnSave_Click(object sender, System.EventArgs e)
{
    int clientValue = Convert.ToInt32(ddlClients.SelectedValue);
}

What can I lose?

+3
source share
4 answers

Has the web farm application been configured? Check out this MSDN article:

http://msdn.microsoft.com/en-us/library/ms998288.aspx#paght000007_viewstate

You need to make sure machineKey is consistent on every server your application is running on. You can define this in web.config. I remember how a previous employer who did not do this had problems with presentation.

+1
source

Like the machine key mentioned above, how is the balancing of your web farm balanced?

Previously, I encountered problems when information comes from one server and is sent back to another.

+1

, , , , , , .

, .

0

ViewState. , , , . ( ViewState), null.

Take a look at "Request.Form [ddlClients.UniqueID]" in the submit form and see if it matters. If this value matters, then .NET rejects the value that was sent back. In this case, it is possible either that the data is not stored in the view, or some code changes the contents of the drop-down list after it is initialized, but before the event is processed.

We hope that one of these suggestions will help you find your way to the problem.

0
source

Source: https://habr.com/ru/post/1713706/


All Articles