如何在我的代码中捕获会话中的id [英] How to catch id in session in my code

查看:60
本文介绍了如何在我的代码中捕获会话中的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai all,我有一个问题,比如在用户注册后用户将重定向到另一个页面,我必须在会话中捕获一些凭据并插入这些值以及第二页凭据







i有电子邮件和姓名,但我能为catch id做些什么帮助



TIA



我尝试过:



Hai all, i have a problem like after user registration user will redirect to another page and i have to catch some credentials in sessions and insert those valus along with second page credentials



i got email and name but what can i do for catch id any help

TIA

What I have tried:

public ActionResult UserRegistration(Tbl_Registration user)
      {
          string name = null, Email = null;
          int userid = 0;


          int i = v.InsertUserRegistration(user.Name, user.Gender,user.email);
          //storing data in session for nexpage
          if (i>0)
          {


              Session["Id"] = user.Id;--id is 0 here
             Session["Name"] = user.Name;

             Session["EmailId"] = user.EmailId;

推荐答案

Session["Id"] = user.Id;--id is 0 here





没有更新user.Id所以它保持在0.尝试





Nothing has updated user.Id so it stays at 0. Try

user.Id = i;
Session["Id"] = user.Id;











or

Session["Id"] = i;


Related to ExecuteNonquery(); , it will return the no of rows affected, so it will "1" if your query worked in database else "0" if query failed due to any reasons.

Here, you can cross check whether user.Id is initialised or not before coming to this block


我猜你的论坛Tbl_Registration用户没有设置Id。如果你点击了If块。然后vari必须大于0,不可能是用户ID存储在那里吗?
Hi, I would guess that your argument "Tbl_Registration user" don't have the Id set. If you hit your If block. Then var "i" must be bigger then "0", can't happen to be that the user id is stored there?


这篇关于如何在我的代码中捕获会话中的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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