Problem with AsyncFileUpload in WebForm (after being published in server) – “AjaxControlToolkit.Properties.Resources.resources” not found

I’m working in a solution created in ASP.NET – Framework 3.5.

This solution has a WebForm (child from a Site.master) with contains multiple UpdatePanels, TabContainer and a single AsyncFileUpload control.

Locally (i.e. in developer enviroment), the WebForm loads and works successfully, but, once published the WebForm in an different server – when a file is selected (by using the AsyncFileUpload control), the following message shows:

Could not find any resources appropriate for the specified culture or
the neutral culture. Make sure
“AjaxControlToolkit.Properties.Resources.resources” was correctly
embedded or linked into assembly “AjaxControlToolkit” at compile
time, or that all the satellite assemblies required are loadable and
fully signed.

In my local developer enviroment, this error does not occur and the file can be selected and processed as expected.


While searching for the causes of this error, most of the suggestions are:

  • Add an ScriptManager or ToolkitScriptManagersource. When tried this option (by adding any of those ScriptManager controls), the WebForm is loaded blank and in the output window – shown in runtime – says: only a single ScriptManager can be added in the page – this is correct, since the ToolkitScriptManager control is already in the Site.master.
  • Check if AjaxControlToolkit.dll is on the bin folder. Checked also and this dll is in the bin folder.

I also tried:

  • Check if AjaxControlToolkit.dll and AjaxControlToolkit.resources.dll is on the bin folder. Those dlls are in the bin folder.
  • Change AsyncFileUpload for FileUpload, but, since this WebForm already uses UpdatePanels, the FileUpload wont work for security reasons – as I tested and the results of Google says so (like this answer, for example).
  • I tried also using only FileUpload and Triggers, but the WebForm contains various UpdatePanels and each time I added the Trigger and PostBackTrigger or AsyncPostBackTrigger. For this reason, I gave up and ended using the AsyncFileUpload control.

What else can be done for check the missing resources and/or the cause of this error and fix this issue?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

First, you don’t want to “place” anything at all in the bin folder. For one, if you do a from the menu build->clean solution then all of the bin files and folders are removed from bin. So, your project needs to work, compile and run without anything in the bin folder WHEN you do a compile, or MORE important when you do a rebuild, and super more important of course is when you create a deploy, then what’s in the bin folder is re-created anyway. So any idea of placing .dll’s in the bin folder is not only a bad idea, but it fruitless and should not be done EVER anyway.

Script manager on the master page. This is good and recommend so you don’t have to mess around doing this page by page.

However, you should tell the script manager what scripts to combine and load.(but different issue – since that should not effect the ajax tool kit.

Where you have to watch is the web.config file. You need to include the ajax tool kit assemblies you are using.

Say like this:

And then in the pages section, you should have/see this:

<pages controlRenderingCompatibilityVersion="4.0">
  <namespaces>
    <add namespace="System.Web.Optimization" />
  </namespaces>
  <controls>
    <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />

    <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
  </controls>
</pages>

IN above – the ajax tookit tag prefix is requied (this enables more of drag + drop of ajax controls on your web forms, but I do have the above – so lets assume you need it.

You should also see/have this:

<httpHandlers>
  <add verb="*" path="AjaxFileUploadHandler.axd" 
     type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</httpHandlers>

Above is under system web.

Now in next section, we have:

<system.webServer>

</handlers>
<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2048000000" />
  </requestFiltering>
</security>

The above will set the max file size. Now the ajax kit does “chunk” – so in theory the above requestlimits may not be required – but it does seem to effect file up-load size.

Now in above, I am using the AjaxFileUpload, and you are using the AsyncFileUpload.

They are similar, but the AjaxFileUpload allows multiple files and displays this screen:

Problem with AsyncFileUpload in WebForm (after being published in server) - "AjaxControlToolkit.Properties.Resources.resources" not found

Also, it not clear how you installed the ajaxtoolkit. I assume nuget?

I suppose in place of a production publish, you might want to spool up a real and full copy of IIS and run that on say some VM, and try publish to that VM.

I mean, on a dev box? Well, you been installing this and that and everything under the kitchen sink for probably 5+ years. That means that ANYTHING going to work and run on your local box – since you gigs and gigs of software and references and whatnot built up over the years. So such a local test vs a publish to a real site means that a local test don’t amount to much at all.

Also, I suppose one might want to look at your project referances.

I see/have this:

Problem with AsyncFileUpload in WebForm (after being published in server) - "AjaxControlToolkit.Properties.Resources.resources" not found

Quite sure, that JUST adding the ajaxtoolkit reference caused all of the above 4 references to occur.

You also don’t mention how you doing the publish. and I assume this is a asp.net web project as opposed to a asp.net web site – since that has limited ability to “setup” for a publish.

All in all, was the ajaxtoolkit installed with nuget, or how did you install and reference the toolkit?

Method 2

I couldn’t solve the problem with the AsyncFileUpload control, but, as a good side, while searching about how to solve this issue, I tried again changing the code and use both FileUpload and UpdatePanel controls.

I came across with this entry – in spanish where it links another thread on another page where it’s explained how to use both FileUpload and UpdatePanel controls.

The linked thread is this: Using FileUpload Control inside ASP.Net AJAX UpdatePanel Control

I changed my code for (instead using AsyncFileUpload) for use FileUpload inside a UpdatePanel, but, here is the catch:

For select and send the file to the server side, the Button that sends
the file (once selected with the FileUpload control) must have
its own UpdatePanel with its respective Triggers tag.


Example: I’m using here a LinkButton control, but, with a Button control should work flawlessly.

In the .aspx:

<asp:UpdatePanel ID="updPnlbtnFileUploadDevols" runat="server">
    <ContentTemplate>
        <asp:LinkButton ID="btnLoadClassFileDevoluciones" runat="server" Text="Cargar Archivo" 
            CssClass="chxbx" ForeColor="Teal" OnClick="BtnLoadChargeFileDevoluciones_Click" ValidationGroup="valChrgFileDevoluciones" CausesValidation="true" />
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="btnLoadClassFileDevoluciones" />
    </Triggers>
</asp:UpdatePanel>

In the aspx.cs:
/// <summary>
/// Load file.
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
protected void BtnLoadChargeFileDevoluciones_Click(object sender, EventArgs e)
{
    try
    {
        if (fupld_cargue.HasFile)
        {
            // Here, the file is detected in server-side 
            // and it's been handled as logic demands it.
        }
        else
        {
            // File not detected in server-side.
            MessageBox("Please, select a file");
        }
    }
    catch (Exception handledException)
    {
        // Omitted exception-handling code in this sample.
    }
}

With the previous explanation, I finally could solve the issue I had about sending a file using FileUpload – which was inside an UpdatePanel control.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x