首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何创建在多个页面中使用的登录用户控件?

如何创建在多个页面中使用的登录用户控件?
EN

Stack Overflow用户
提问于 2010-01-11 02:42:59
回答 2查看 704关注 0票数 0

我想在asp.net mvc站点中创建登录用户控件,以便在多个页面中使用我有视图、控制器、模型的普通页面,我将如何处理此用户控件的所有这些东西

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-01-11 03:07:25

代码语言:javascript
运行
复制
<% 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指向~/Views/Shared/Sidebar/LoggedInSidebar.ascx
  • LogInSidebar指向~/Views/Shared/Sidebar/LogInSidebar.ascx
票数 0
EN

Stack Overflow用户

发布于 2010-01-11 05:45:49

愚蠢的问题@Ahmed,但您不能使用在创建新的MVC项目时生成的问题吗?

它位于名为LogOnUserControl.ascx的共享文件夹中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2038076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档