martedì 8 settembre 2015

DotNetNuke Input string was not in a correct format

Yesterday all my my DNN 7.3.4 portals show an  a generic error message and didn't show any content.
I was able to login as superuser and could check that the real error was "DotNetNuke Input string was not in a correct format".
Every module gave this error.
I spent a day to found the couse to this problem, I checked a lot of blog about this error without success.
Finally I found that everything was coused by a malware attack, probably due to a DNN vulnerability.
I dont' know how, but table ModuleSettings was updated and value on column SettingValue was changed joining the oringinal value to a html string, take a look to the picture:


To repair the table I used the following sql script:
update [ModuleSettings] set SettingValue=case when CHARINDEX('<',SettingValue)>1 then SUBSTRING(SettingValue,1,CHARINDEX('<',SettingValue)-1) else '' end

after this I had to manually delete the cache removing files in [Portal]/Cache/Pages and restart the application.

This make me think that a vulnerability exists on DNN 7.3.4, hope this help to fix it.

lunedì 10 settembre 2012

Iron Speed Import

I noticed there's a little issue in Iron Speed importing process.
When you try to import a csv file and a column has a foreign key to a filed table having  Dispay As attribute compose by more then one column of the linked table, the import process fail, or try to create a new record in the linked table even if the record exists.

An example could make the situation clear:
tables: userInfo, projects
fk: projects.user_id -> userInfo.user_id
projects.user_id has the following display as expression: userInfo.serialCode+ " " + userIndo.Name

In other words the method GetDFKA in ImportDataItems can't translate the imported column to the corredponding primary key beacuse of the expression on Display as.

I found a little workaround, changing a bit the code of GetDFK, so the methos return the first valid column found.
For me it works because my first field was the one that is present in the cvs to import.

The code:

 public static string GetDFKA(ForeignKey fkColumn)
        {
            bool isDFKA = false;
            if (fkColumn == null) {
                return null;
            }
            string _DFKA = fkColumn.PrimaryKeyDisplayColumns;

            // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation
            string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
            string column = _DFKA.Trim('=').Trim();
            if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase)) {
                //column = column.Substring(tableCodeName.Length + 1);
               
               
            }
            int pos = -1;
            foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
            {
                int currPos=column.ToLower().IndexOf(tableCodeName + "."+c.CodeName);
                if (currPos>=0)
                {
                    isDFKA = true;
                    if (pos==-1 || currPos < pos)
                    {
                        column = c.CodeName;
                        pos = currPos;
                    }
                    //break;
                }
            }

            /*
            foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns) {
            if (column == c.CodeName) {
                isDFKA = true;
                break;
                }
            }
             */

            if (isDFKA) {
                return column;
            } else {
                return null;
            }
        }

venerdì 31 agosto 2012

IIS Alternatives

Searching for an alternative to IIS in Windows Xp Home I found an amazing product: Couldnt' believe that my .net 4.0 with sql server db could work with it without wasting time tuning and configuration. Really a valid alternative to IIS as embedded web server or a web server in a destop enviroment.