IO操作后,ASP.NET MVC会话变为空

时间:2016-05-28 04:48:23

标签: asp.net asp.net-mvc

这是我写的代码。

  if (propertyModel.PropertyName.Replace(" ", "") != model.PropertyName.Replace(" ", "") && propertyModel.PropertyRegistrationCompletedPercentage >= 71)
                    {
                        var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\ProprtyImages", Server.MapPath(@"\")));
                        string pathString = System.IO.Path.Combine(originalDirectory.ToString(), propertyModel.PropertyName.Replace(" ", "") + "__" + User.Identity.GetUserId().Replace("-", "") + "__" + "propertyid" + "__" + propertyModel.PropertyId.ToString());
                        string newpathstring = System.IO.Path.Combine(originalDirectory.ToString(), model.PropertyName.Replace(" ", "") + "__" + User.Identity.GetUserId().Replace("-", "") + "__" + "propertyid" + "__" + propertyModel.PropertyId.ToString());
                        bool isExists = System.IO.Directory.Exists(pathString);
                        if (isExists)
                        {
                            Directory.Move(pathString, newpathstring);
                        }
                        else
                        {
                            ViewBag.Message = "Unexpected IO error occurred.";
                            return View("ErrorPageWithCustomMessage");
                        }
                    }
                    Session["PropertyRegistrationCompletedPercentage"] = propertyModel.PropertyRegistrationCompletedPercentage;
                    Session["IsPropertyBeingStartedToAdd"] = propertyModel.IsPropertyBeingStartedToAdd;
                    Session["IsPropertyAddingCompleted"] = propertyModel.IsPropertyAddingCompleted;
                    Session["IsThePropertyVerified"] = propertyModel.IsThePropertyVerified;

当我尝试在重定向到另一个操作后检索会话变量时,这些值是如何解决的?

0 个答案:

没有答案