开发者

MVC View Alternate Content

I have a view which I want to display different things based on a database field.

  • An authenticated user who has purchased an item should see it in full
  • Authenticated or Anonymous members who have not purchased the item shou开发者_开发知识库ld see a preview

The only data this means changing is the title (prefix the word Preview) and changing the source of the video.

Any suggestions about how to do this and if there is a better approach would be appreciated thanks.


Could I detect the route and base the information from this?

for example: /preview/slug and /purchased/slug?


Well, it should be nothing more than a few if blocks in your view:

  <asp:Content ContentPlaceHolderID="TitleContent" runat="server">View Video<% if (!Model.IsAuthenticated) { %> Preview<% } %></asp:Content>

You could do something similar for setting the source of the video as well, you just need to create and populate a property like IsAuthenticated (or similar) in your model....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜