ASP.NET iframe routing - loading JS files in incorrect order

46
April 12, 2021, at 5:30 PM

I have an issue with JS files being loaded in incorrect order, which results in errors.

I am using an iframe with src="/Load/0001/index.html" and i am routing this url to a controller Content/GetFile(0001,"index.html"). Controller is fetching the index page and all related files (including JS) from database and sending them to client via Response.OutputStream.Write();

This procedure is working correctly:

long _long_bytesToRead = _stream_content.Length;
string _str_extension = path.Substring(path.IndexOf('.') + 1);
 Response.ContentType = this.GetFileContentType(_str_extension);
                while (_long_bytesToRead > 0)
                {
                    if (Response.IsClientConnected)
                    {
                        byte[] _buffer = new byte[4096];
                        int _readLength = _stream_content.Read(_buffer, 0, _buffer.Length);
                        try
                        {
                            Response.OutputStream.Write(_buffer, 0, _readLength);
                            Response.Flush();
                        }
                        catch (Exception e)
                        {
                            Response.End();
                            //LOG FATAL: Response exception
                        }
                        _long_bytesToRead -= _readLength;
                    }
                    else
                    {
                        _long_bytesToRead = -1;
                    }
                }

My problem is that JS files, that are requested by iframe in proper order take different time to be fetched from database and sent to client, which means that some files are transfered earlier than others and JS throws an error because it does not recognize variables defined in preceding scripts.

Note: I cannot influence or change the content of the index page and related javascripts. Its provided by 3rd party and needs to be kept as is...

Also. Before using database we tested this routing solution with files being read from filesystem and it worked properly for all examples. It seems to be an issue of the MSSQL databasem which is providing the files, or maybe controller being allowed to finish transfers in incorrect order.

Is there a way to ensure that files will come in correct order, even though the transfer takes different time for each particular one?

READ ALSO
Mongodb update field based on another field at a specific time (mongoose)

Mongodb update field based on another field at a specific time (mongoose)

As the title suggests I want a field to be updated automatically at a specific time based on another fieldFor example, we have the following schema:

38
SpringBoot + Thymeleaf + SQL, display HTML table from database

SpringBoot + Thymeleaf + SQL, display HTML table from database

I want to create siteI have already configured login "/login" and registration "/registration" pages

56
How to use elasticsearch rangequery to find values that are less than or equal to a number value in Java API

How to use elasticsearch rangequery to find values that are less than or equal to a number value in Java API

Hello I'm new to Elastic Search and I'm trying to build an elastic search query using Java APII have the following

71