我有一个网站,用户出现并注册,注册有三个部分如下
在第3部分之后,我然后对用户进行身份验证并将其登录,我试图弄清楚的问题是当他们从第1部分到第3部分时,我需要在第1部分之后跟踪它我将保存数据库中的值并为该用户返回一个UniqueId并将其存储在会话中并在第2部分和第3部分中引用它,我在过去的会话中遇到了一些问题,它超时了I& #39;我试图想出一个具体的解决方案来代替会话。我确实试过谷歌搜索这个,但看看世界上是否有其他人做过类似但没有运气的东西,因此为什么我决定在这里问这个。
答案 0 :(得分:0)
如果您希望它们能够关闭浏览器并稍后继续,您将需要使用Cookie来存储用户的进度。如果不知道你的完整项目就很难给出一个确切的解决方案,但这绝对可以帮助你。
public ActionResult Signup()
{
//The cookie could be stored in the format: partnumber_databaseid
//An example cookie would look like 1_24
if (request.Cookies["SingupProgress"] != null)
{
var part = request.Cookies["SignupProgress"].ToString().Split('_')[0];
var id = request.Cookies["SignupProgress"].ToString().Split('_')[1];
//Eg if the cookie stored number "1" as part, the returned view would be "Part2"
//Return the stored part number plus one, as the part number will represent which part they have already completed
string ViewName = "Part" + part + 1;
return View(ViewName);
}
else
{
//If the cookie doesn't exist, that means the user has not made any sign up progress
//Direct them to the first signup part
return View("Part1");
}
}
public ActionResult Part2()
{
//Direct the user to this action once they have clicked next on the Part 1 view
//Create the class to store the progress data.
//You also need this to extract the Unique ID for the cookie
ProgressClass Progress = new ProgressClass(/*Your data*/);
//Store the progress into the database
db.StoreProgressData();
db.Save();
//Get the unique ID that you just saved into the database
int Id = Progress.Id;
HttpCookie ProgressCookie = new HttpCookie("SignupProgress", Id + "_2");
}
//Once they reach part 3 your final link can direct them to a register action, which creates the account and saves it to a database