admin管理员组

文章数量:1125360

[HttpGet]
public ActionResult PopulateSearchFields(string Id = "", string FreeText = "", string Subject = "", string IdType = "", string IdNumber = "",
                                         string AccessionNumber = "", string Branch = "", string RRVisitNumber = "", string HealthSource = "", string HealthFactor = "")
 {


        string indexPageURL = $"/User/Index?Id={HttpUtility.UrlEncode(Id)}";
        return Redirect(indexPageURL);
 }

This function interact "Index function" , I debbuged and check "Id" parameter and the value is not null, but from some reason when I redirect to Index function Id inside "Index" get null value.

    public virtual ActionResult Index(string Id)

    //CommonConsts.GlobalSettings = SystemMethods.GetGlobalSettings();
    {
        try
        {

            Systems.GlobalSettings = SystemMethods.GetGlobalSettings();
            ViewBag.Version = UtilityMethods.GetVersion();
            ViewBag.Subjects = ConnectionsMethods.SubjectsFromDB();

            var Districts = ConnectionsMethods.DistrictsFromDB();
            var startDistrict = new District() { REF = "-1", Name = "" };
            Districts.Insert(0, startDistrict);
            ViewBag.Districts = Districts;

            UserAD userAD = UserMethods.UserADByLoginFromDB(User.Identity.Name.Substring(
                User.Identity.Name.LastIndexOf("\\") + 1), true);
            ViewBag.UserAD = userAD;
            ViewBag.UserName = userAD.UserFullName;

            ViewBag.Settings = SystemMethods.GetSettings(userAD);
            ViewBag.Theme = ViewBag.Settings.Theme;

            ViewBag.Branches = ConnectionsMethods.FetchNamesOfBranches();
            ViewBag.HealthFactors = ConnectionsMethods.FetchHealthInsuranceFactors();
            ViewBag.InsuranceFactorSources = ConnectionsMethods.FetchHealthInsuranceSources();
            ViewBag.IdTypes = ConnectionsMethods.FetchIdTypes();    

            ViewBag.MessageIcons = ConnectionsMethods.GetMessageIcons();
            ViewBag.RefreshTime = Systems.GlobalSettings.RefreshTime;
            ViewBag.UserMetricsTag = Systems.GlobalSettings.UserMetricsTag;
            ViewBag.LoadProjectsCnt = Systems.GlobalSettings.LoadProjectsCnt;
            ViewBag.Users = new SelectList(UserMethods.UsersAdFromDB(), "Value", "Text");
            ViewBag.AwayInterval = Systems.GlobalSettings.AwayInterval;

            ViewBag.Tabs = BuildTabs(userAD);
            ViewBag.HasAutoSearch = 0;

            var autoSearch = new AutoSearch(Id);
            if (UtilityMethods.IsAutoSearchEnabled(autoSearch))
            {
                ViewBag.HasAutoSearch = 1;
                ViewBag.AutoSearch = autoSearch;
            }

        }
        catch (Exception ex) 
        {
            Systems.logger.Error(User.Identity.Name + " " + ex.Message);   
        }  


        return View();
    }

Is someone know why it happnes? I can call index directly but I want to get more elegant code

本文标签: cTrying to redirect with function parametersStack Overflow