ahmed salah

ahmed salah

  • 1.1k
  • 547
  • 51.4k

I can't pass role and file from action to action using hidden field

Jan 9 2024 9:31 PM

I work on asp.net mvc . i face issue when pass user role and User code

from IndexResignation action to PendingManagersRequests action using

session because it share values between browsers .

so How to use another way instead of session as hidden field .

public ActionResult IndexResignation(string filenumber)
 {
     int employeeFileNo;
     string userRole;
     

     
     if (!string.IsNullOrEmpty(filenumber))
     {
         
         if (int.TryParse(filenumber, out employeeFileNo))
         {
             JDEUtility jde = new JDEUtility();
             userRole = Workforce.ResignationGetUserRole(employeeFileNo);

            
                 Session[SessionKeys.UserCode] = employeeFileNo;
             if (!string.IsNullOrEmpty(userRole))
             {
                 
                 Session[SessionKeys.RoleCode] = userRole;
             }
          
             if (userRole == RoleKey.LM || userRole == RoleKey.DM || userRole == RoleKey.LDM)
             {
                 
                 return RedirectToAction("PendingManagersRequests", "Resignation", null);
             }
            
             

         }
         else
         {
             ViewBag.errorMsg = "incorrect file no";
         }
     }
     else
     {
         ViewBag.errorMsg = "unauthorized user";
     }
    
     return View();
 }

     public async Task<ActionResult> PendingManagersRequests(string msg, string errorMsg)
     {
        // how to pass user role and user code to action PendingManager
     }

 

can you show me view and action what will be if i use hidden fields ?

Index resignation action not have view

PendingMangerRequest action have view


Answers (2)