我想在asp.net mvc网站中创建登录用户控件,以便在多个页面中使用 对于普通页面,我有视图,控制器,模型我将如何处理这个用户控件的所有这些东西
答案 0 :(得分:0)
<% 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"); %>
<% }
~/Views/Shared/Sidebar/LoggedInSidebar.ascx
~/Views/Shared/Sidebar/LogInSidebar.ascx
答案 1 :(得分:0)
愚蠢的问题@Ahmed但您不能使用创建新MVC项目时生成的那个吗?
它位于名为LogOnUserControl.ascx的共享文件夹中。