Guest User

Untitled

a guest
Jun 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
  2. <%
  3. if (Request.IsAuthenticated) {
  4. %>
  5. Welcome <b><%= Html.Encode(Page.User.Identity.Name) %></b>!
  6. [ <%= Html.ActionLink("Log Off", "LogOff", "Account") %> ]
  7. <%
  8. }
  9. else {
  10. %>
  11. [ <%= Html.ActionLink("Log On", "LogOn", "Account") %> ]
  12. <%
  13. }
  14. %>
  15.  
  16. <%= Html.LoginStatus() =>
  17.  
  18. /Views/Shared/LoginStatus.Anonymous.ascx
  19. /Views/Shared/LoginStatus.Authenticated.ascx
  20.  
  21. <asp:LoginView Runat="Server">
  22. <LoggiedInTemplate>
  23. Welcome, <%= Html.Encode(Model.UserName) %>!
  24. <button>Sign Out</button>
  25. </LoggedInTemplate>
  26. <AnonymousTemplate>
  27. <button>Sign In</button> | <button>Join Now!</button>
  28. </AnonymousTemplate>
  29. </asp:LoginView>
  30.  
  31. public ActionResult ShowAPage()
  32. {
  33. if(!HttpContext.User.Identity.IsAuthenticated)
  34. {
  35. return RedirectToRoute("ShowLoginPage")
  36. }
  37. return View();
  38. }
  39.  
  40. public ActionResult ShowAPage()
  41. {
  42. if(!HttpContext.User.Identity.IsAuthenticated)
  43. {
  44. return View("ShowAPageView", "LoggedInMasterPageName");
  45. }
  46. return View("ShowAPageView", "LoggedOutMasterPageName");
  47. }
Add Comment
Please, Sign In to add comment