I have written code which retrieves data from ClientID
and modifies it to Int32
. There's no error while debugging. I've deployed the site to network. It is working as intended when accessed through same LAN where server is located. However is throwing an error when others (outside this Network) are trying to login to site.
The error is:
Server Error in '/' Application
Exception Details: System.FormatException : Input string was not in a correct format.
PS: The site is accessible. They are able to register, change password and redirect to different pages from home page. However, when profile loads they are seeing the error.
I've tried to debug again, check with db (mySQL) connectivity, refreshed the IIS server manager completely, Checked with the permissions, tried to change the "Int to Var" in cs code, remove "value=" and ".text()" from the error line and deployed the site again multiple times with modifications each time debugging.
function getdays(date){
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var d = new Date(date);
var dayName = days[d.getDay()];
var selecteddays = value = $('#<%=lblweekoff.ClientID%>').text();
var selectedSplittedDays = selecteddays.split(',');
}
C#
string MyConString = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
var dayColumns = new[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
var selectedDayColumn = dayColumns[(int)nextDate.DayOfWeek];
var sp = (dr["p"].ToString());
Int sp1 = Convert.ToInt32(sp);
MySqlConnection connection = new MySqlConnection(MyConString);
The code should be able to accept the number and load the page with the calculation with respect to number given and split the days which are divided by "," stored in database.
It should allow the user to login in and show the page without any error. As it is running as intended with in same LAN, I don't think there is a serious problem with the code. However, all the suggestions would be highly appreciated.
UPDATE : To explain further, there are 2 sets of predefined users, lets say set A has 100 users and set B has 100 users. When I place myself as a user in set A, I'm able to login to the site. When I'm in set B, I'm unable to login and its casting same error.
I've removed entire set B and added inserted updated details. Still it's posing same error for all the users in set B. Set A however doesn't have any problem logging in and accessing the features.
I think the error is with $('#<%=lblweekoff.ClientID%>')
. Further with all the ClientID
functions. I've tried to comment the error line and tried to execute where I've received error with another .ClientID
function. So, would the issue be with the code interacting with db?
If that's the case, they are able to register or change password which links to the same db.
I got it!
The input was in int form.
Int sp1 = Convert.ToInt32(sp);
However, the inputs data were float(decimal numbers).
Corrected it to:
float sp1= math.round(Convert.ToInt32(sp));
It actually worked. Thank you all for suggestions and help.