无法转换httpcontext.current.user.identity [英] can not convert httpcontext.current.user.identity

查看:71
本文介绍了无法转换httpcontext.current.user.identity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将此httpcontext.current.user.identity转换为int,因为我在db中有一个字段为user_id,其类型为int ...我需要在登录后通过webform page填充它。我知道它不能总共投了

但我怎么能在db中填写这个字段?我的意思是cmd.parameters.addwith value(user_id,httpcontext.current.user.identity);

,它显示错误?

我该如何解决?

感谢您考虑我的问题。

i can not cast this httpcontext.current.user.identity to int because i have a field in db as user_id and its type is int...i need fill it after login by a webform page.i know it cant be cast at all
but how can i fill this field in db?i mean cmd.parameters.addwith value("user_id",httpcontext.current.user.identity);
and it show me error?
how can i solve it?
thank you for consider my question.

推荐答案

我有一个表作为用户(id int,用户名nvarchar,密码varchar)

然后我有一个forumtable(id int,user_id int,title nvarchar,bodytext ntext)

我的登录和注册工作正常。甚至mt cms的所有部分都正常工作。

但是在我的cms中,每当我需要db_id中的user_id时,我用ddl和sql数据源填充这个字段,它是对我来说简单而且好看。但现在我在论坛中有一个应该在登录后点击发送按钮后填写user_id的apage。我确实喜欢它

cmd.parameters.addwithvalue(user_id,httpcontext.current.user.identity);

但它显示我的演员错误..转换所有到int.parse或字符串仍然有错误。

i不能将user_id更改为table2中的字符串因为在我的用户表中userid是int类型而这个user_id是第二个表的fk ...

所以我该如何解决我的问题呢?



thx
i have a table as users(id int,username nvarchar,password varchar)
then i have a forumtable(id int,user_id int,title nvarchar,bodytext ntext)
my login and register work correctly.even all part of mt cms work correct.
but in my cms whenever i need user_id in db i fill this field by a ddl and sql datasource and it was easy and nice to me.but now i have apage in forum that should fill user_id after click in send button after login. i did sth like it
cmd.parameters.addwithvalue("user_id",httpcontext.current.user.identity);
but it show me cast error..i convert all to int.parse or string still have error.
i cant change user_id as string in table2 cause in my user table the userid is int type and this user_id is a fk for second table...
so how can i solve my problem?

thx


这篇关于无法转换httpcontext.current.user.identity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆