C# 如何在asp.net中获取cmos日期/时间
我正在asp.net中开发一个应用程序,我想创建一个7天的演示版本。。我试图在asp.net中停止演示,方法是检查当前日期,如果是过去7天,则检查应用程序。不会启动。 但问题是用户先从windows控制面板更改日期,然后再从应用程序更改日期。无法检测到它,它将运行。。我想在不在线的情况下拍摄cmos日期/时间C# 如何在asp.net中获取cmos日期/时间,c#,C#,我正在asp.net中开发一个应用程序,我想创建一个7天的演示版本。。我试图在asp.net中停止演示,方法是检查当前日期,如果是过去7天,则检查应用程序。不会启动。 但问题是用户先从windows控制面板更改日期,然后再从应用程序更改日期。无法检测到它,它将运行。。我想在不在线的情况下拍摄cmos日期/时间 int num=7; int smonth=convert.toint32(Datetime.Now.Date.Tostring()); if ((nu
int num=7;
int smonth=convert.toint32(Datetime.Now.Date.Tostring());
if ((num < smonth) || (num == smonth))
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('Please Update your Licence Key');", true);
}
else
{
if (crt_val == "0")
{
Session["UserId"] = txtusername.Text.Trim();
objuser.UserCode = txtusername.Text.Trim();
objuser.Password = s_hex_md5(txtpassword.Text.Trim());
string pwd = s_hex_md5(txtpassword.Text);
objuser.Ccode = ddlCode.SelectedValue;
objuser.Lcode = ddlLocation.SelectedValue;
DataTable dt = new DataTable();
dt = objdata.UserLogin(objuser);
if (dt.Rows.Count > 0)
{
if ((dt.Rows[0]["UserCode"].ToString().Trim() == txtusername.Text.Trim()) && (dt.Rows[0]["Password"].ToString().Trim() == pwd) && (dt.Rows[0]["CompCode"].ToString().Trim() == ddlCode.SelectedValue) && (dt.Rows[0]["LocationCode"].ToString().Trim() == ddlLocation.SelectedValue))
{
Session["Isadmin"] = dt.Rows[0]["IsAdmin"].ToString().Trim();
Session["Usernmdisplay"] = txtusername.Text.Trim();
Session["Ccode"] = dt.Rows[0]["CompCode"].ToString().Trim();
Session["Lcode"] = dt.Rows[0]["LocationCode"].ToString().Trim();
if (Session["Isadmin"].ToString() == "1")
{
Session["RoleCode"] = "1";
}
else
{
Session["RoleCode"] = "2";
}
Response.Redirect("Dashboard.aspx");
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('User Name and Password Wrong');", true);
}
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('Please Update your Licence Key');", true);
}
}
else
{ }
}
int num=7;
int smonth=convert.toint32(Datetime.Now.Date.Tostring());
if((num0)
{
如果((dt.Rows[0][“UserCode”].ToString().Trim()==txtusername.Text.Trim())&&(dt.Rows[0][“Password”].ToString().Trim()==pwd)&(dt.Rows[0][“CompCode”].ToString().Trim()=ddlCode.SelectedValue)&(dt.Rows[0][“LocationCode”].ToString().Trim()=ddlocation.SelectedValue))
{
Session[“Isadmin”]=dt.Rows[0][“Isadmin”].ToString().Trim();
会话[“Usernmdisplay”]=txtusername.Text.Trim();
会话[“Ccode”]=dt.Rows[0][“CompCode”].ToString().Trim();
Session[“Lcode”]=dt.Rows[0][“LocationCode”].ToString().Trim();
如果(会话[“Isadmin”].ToString()=“1”)
{
会话[“角色代码”]=“1”;
}
其他的
{
会话[“角色代码”]=“2”;
}
重定向(“Dashboard.aspx”);
}
其他的
{
ScriptManager.RegisterStartupScript(this,this.GetType(),“窗口”,“警报('用户名和密码错误');”,true);
}
}
其他的
{
ScriptManager.RegisterStartupScript(this,this.GetType(),“窗口”,“警报('请更新您的许可证密钥');”,true);
}
}
其他的
{ }
}
请任何人帮助我…当用户更改控制面板中的时间时,用户正在更改CMOS日期/时间 您可能希望让应用程序联机与时间服务器联系以获取正确的日期/时间 关于如何在这里做这件事的极好答案
DateTime
C#中的结构提供运行代码的机器的日期和时间详细信息。因此,如果您想向客户机提供演示应用程序,可以将该应用程序部署在您控制的服务器上。因此,用户无法控制更改日期和时间,即使客户端更改日期和时间,也不会影响应用程序,因为应用程序代码在不同的计算机上运行
DateTime.Now gives you the Current date and time of the Server
因此,我建议维护一个专用的服务器
,用于为客户部署/维护网站。一天后问同样的问题不会改变这样一个事实,即试图获取BIOS时间是毫无意义的,或者发布的代码与此无关。如何处理此转换为32(Datetime.Now.Date.Tostring())
会起作用吗ToInt32
无法识别日期和时间的文本表示形式。它甚至没有编译。