1

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 ToolkitScriptManager - source. 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?

2 Answers2

0

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:

enter image description here

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:

enter image description here

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?

Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51
  • Thank you for your feedback. problems are: I don't make the publish, this is made by another person. The ajaxcontroltoolkit is already in use - I don't know how was added (*if via NuGet, or directly added the dll*) and the problem is only in this webpage with the AsyncFileUpload control and when a file is selected - the rest of the components (*both from ajaxcontroltoolkit and ASP.NET*) are working. Each webform/webpage has its own register tag for register user controls and other components: like `<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>` - – Marco Aurelio Fernandez Reyes Dec 22 '20 at 13:22
  • Check the page for any JavaScript errors (f12 in browser). Your local build should work without the ajax.dll's being manual placed in the bin folder. Correct references to the ajax dll's should during a compile wind up placing those .dll's each time in the bin folder. Clean project empties out bin folder files anyway (you should have use of clean project). Strange other toolkit parts used work, thus this may not be deployment/compile time issue. I would get the project working and ensure that reference settings to ajaxtoolkit.dll's are NOT pointing to bin folder, but the ajax toolkit folder. – Albert D. Kallal Dec 22 '20 at 21:24
  • I've checked the console (*F12 in browser*) and no errors; I'm still looking for how I can reproduce this error - I don't have access to the server(s). I was thinking if *maybe* this errors is due to security reasons - maybe the AsyncFileUpload control gets information/resources outside the dll - like *online* resources of some sort... I cannot promise the creation of a VM for replicate this erros, but, I'll keep it in mind - project is quite large and time is out, unfortunately. – Marco Aurelio Fernandez Reyes Dec 23 '20 at 16:11
  • Albert, can you please add more information about `AjaxFileUploadHandler.axd`? - I've never saw that tag in neither local or server web.config. – Marco Aurelio Fernandez Reyes Dec 23 '20 at 17:15
0

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.