【发布时间】:2013-10-17 23:40:00
【问题描述】:
为我的网站使用表单身份验证,我收到错误
if (reader1.Read())
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
tbDomainID.Text,
DateTime.Now,
DateTime.Now.AddMinutes(30),
true,
role = reader1.GetInt64(0),// this line
FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName,
hash);
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
Response.Cookies.Add(cookie);
当我将它从 GetString(0) 转换为 GetInt64(0) 时,会显示另一个错误
无法将类型“long”隐式转换为“string”
谁能告诉我哪里出了问题或者我应该怎么做。
我正在从我的数据库中获取整数值。
【问题讨论】:
-
角色需要一个字符串。你给它一个 Int64(即长)
-
如何给角色一个整数值
-
我已经写了 3 个 cmets,但老实说,我的文字让我失望.... 投票关闭 ...
-
我花了一段时间才找到有用的东西,但是拜托 read this
标签: c# string casting int form-authentication