Я вижу каждый день в моей Elmah этой ошибке. Как это исправить?Строка ввода не была в правильном формате. в C# ASP.NET
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 40: {
Line 41: String Pass = password.Text;
Line 42: Int64 UserName = Convert.ToInt64(username.Text);
Line 43:
Line 44: if (Convert.ToInt32(Session["FaildLoginTime"]) == 5)
Source File: c:\Inetpub\vhosts\domin.com\my.domin.com\WebMaster\LoginMaster.master.cs Line: 42
Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +11793873
System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt) +133
System.Convert.ToInt64(String value) +51
WebMaster_LoginMaster.btnLogin_Click(Object sender, EventArgs e) in c:\Inetpub\vhosts\domin.com\my.domin.com\WebMaster\LoginMaster.master.cs:42
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9696694
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639
Вы пытаетесь преобразовать строку в Int64, если вы пытаетесь конвертировать что-то вроде ККК это поднимет исключение ... Convert.ToInt64() работает только со строками, содержащие числа. –
запишите значение 'username.Text' ... Убедитесь, что это не пустая строка или содержат нечисловые символы. – user1666620