C
C#8mo ago
Holyschytt

❔ Incurable ERROR ???

I am trying to Post a database strings and ints to a webpage using C# I keep getting
System.FormatException: 'Input string was not in a correct format.'
System.FormatException: 'Input string was not in a correct format.'
The line that triggers this is
byte[] data = Encoding.UTF8.GetBytes(string.Format(pageData));
byte[] data = Encoding.UTF8.GetBytes(string.Format(pageData));
And it points to this static string Line 52
"<script type = 'text/javascript'>" +
Line 40: " var data = " +
"[{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}] " +
" var container = document.getElementById('Online Servers');" +
Line 52: " var hot = new Handsontable(container, {data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true});" +
"<script type = 'text/javascript'>" +
Line 40: " var data = " +
"[{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}] " +
" var container = document.getElementById('Online Servers');" +
Line 52: " var hot = new Handsontable(container, {data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true});" +
Now when i fix the Line 52 With {{}} Line 40 does the same but when there both fixed i get nothing on the page its blank
9 Replies
Holyschytt
Holyschytt8mo ago
This is What it wants i guess
"<script type = 'text/javascript'>" +
" var data = " +
"[{{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}}] " +
" var container = document.getElementById('Online Servers');" +
" var hot = new Handsontable(container, {{data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true}});" +
"<script type = 'text/javascript'>" +
" var data = " +
"[{{'" +
"'ServerID': 1," +
"'ServerName': 'Default Server'," +
"'ServerPassword': 'UNCHANGEDME'," +
"'ServerCurConnections': '0'," +
"'ServerMaxConnections': '32'," +
"'ServerIP': '127.0.0.1'," +
"'ServerPort': '7728'," +
"'ServerLocked': 'true'" +
"}}] " +
" var container = document.getElementById('Online Servers');" +
" var hot = new Handsontable(container, {{data: "+ HostManagment.GetServerList()+", rowHeaders: true, colHeaders: false," +
" colHeaders: ['ServerID','ServerName','ServerPassword','ServerCurConnections','ServerMaxConnections','ServerIP','ServerPort','ServerLocked'], " +
" columnSorting: true, " +
" sortIndicator: true}});" +
Thinker
Thinker8mo ago
the issue (I assume) is the fact you have unescaped {} in your code Also please god use raw strings literals
"""
<script type = 'text/javascript'>
var data = [{{
...
}}]
"""
"""
<script type = 'text/javascript'>
var data = [{{
...
}}]
"""
Holyschytt
Holyschytt8mo ago
Yes so i correct it with the following but then the it doesnt work nothing happens @🌈 Thinker 🌈 Raw Strings??? all code is lit in errors
Holyschytt
Holyschytt8mo ago
No description
Thinker
Thinker8mo ago
what's your language version
Holyschytt
Holyschytt8mo ago
11
Thinker
Thinker8mo ago
oh wait put the ending """ on its own line
Holyschytt
Holyschytt8mo ago
Nope same but i figured it out I put it all in one line with out the "code" + next line etc and it worked. so its string webpage = "Webpagecode"; webpage showed and worked. That makes no sense at all now its all working as i hit enter to put them in seperate lines. with " + and it still works Oh shit i am on version 10 not 11 fixed. thanks @🌈 Thinker 🌈
Accord
Accord8mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts