2
Answers

How to redirect to another view

Photo of prabhu p

prabhu p

7y
193
1
In MVC5, I have one question,
 
Iam calling one Action Method(second page) from jquery from First page button click
Everything working fine but atlast i need second action metod view want to load.
could any one help on this.
  1. $('#report').click(function () {  
  2. debugger  
  3. $.ajax({  
  4. url: '@Url.Action("loadreport", "Report")',  
  5. type: 'GET',  
  6. data: { Mid: $(Txt_Monitor).val() },  
  7. cache: false,  
  8. success: function (data) {  
  9. $("#contact").html(data);  
  10. $header = $('.header');  
  11. $("#div1").show();  
  12. $header1 = $('.header tr td');  
  13. var x = $header.find('td');  
  14. var k = $header1.find('div');  
  15. $('.panel-body').on('scroll'function () { $header.css('top', $(this).scrollTop()); });  
  16. //var wi = new Array();  
  17. //$('.dt tr').eq(0).find('td').each(function (e) {  
  18. // k.eq(e).width($(this).width() );  
  19. // wi.push(k.eq(e).width());  
  20. //});  
  21. $('.dt thead tr td div').each(function (e) {  
  22. k.eq(e).width($(this).width());  
  23. });  
  24. $("#spinner").hide();  
  25. },  
  26. error: function () {  
  27. // handle ajax error  
  28. $("#spinner").hide();  
  29. }  
  30. });  
  31. });  
  32. });  
Second action method
  1. public ActionResult loadreport(string Mid)  
  2. {  
  3. int TV = RTS.LoadTV(Mid);  
  4. ViewBag.loadreport = RTS.Loadreport(Mid, TV);  
  5. //ViewData["loadrep"] = new SelectList(loadreport, "Rel_Type", "Rel_Type");  
  6. return View();  
  7. }  
please help on this

Answers (2)

0
Photo of Rahul Kaushik
NA 383 14.6k 7y
There is a perfect way while using flag to detect whether someone is already logged in or not and in case if System get power off , you need an event handler called as SystemEvents.SessionEnds.
 
Use this to change the flag value from true to false
 
Use this link as a reference
https://stackoverflow.com/questions/6799955/how-to-detect-windows-shutdown-or-logoff 
0
Photo of Mann Maurya
NA 47 869 7y
Hey Ajeesh
 
one more question... ??
 
If power off happen then how you suppose to Reset the flag
 
0
Photo of Ajeesh
NA 349 1.6k 7y
You can take a look at this article which discuss a similar topic. 
 
https://blog.learningtree.com/preventing-duplicate-logins-in-asp-net/
 
Another option would be to have a flag in your table and set the value to true when an user login and when user log off set the value to false.  Also for when a second user tries to login we will first check if login flag has been set to true for any other user. If its true then show message to user and display the login page, if not allow the user to login.