tags:

views:

65

answers:

2

I want to create login user control in asp.net mvc site , to be used in multiple pages for the normal pages i have view , controller , model how i will handle all this stuff for this user control

A: 
<% if(User.IsAuthenticated) { %>
  <%-- User is logged in, show them the sidebar to do with their account --%>
  <% Html.RenderPartial("Sidebar/LoggedInSidebar"); %>
<% } else { %>
  <%-- User needs to log in, show them a sidebar that asks for their credentials --%>
  <% Html.RenderPartial("Sidebar/LogInSidebar"); %>
<% }
  • LoggedInSidebar points to ~/Views/Shared/Sidebar/LoggedInSidebar.ascx
  • LogInSidebar points to ~/Views/Shared/Sidebar/LogInSidebar.ascx
Dan Atkinson
A: 

Silly question @Ahmed but can't you use the one that is generated when you create a new MVC project?

It's in the Shared folder called LogOnUserControl.ascx.

griegs
Silly reply @griegs because I need login control Username/password not action links
Ahmed