I am new in developing using asp.net.
I use java(struts2) to do the web application before,it is easy to control this use the jsp tag or struts2 tags: For example(suppose the "do something" operation need use login):
<s:if test="#session.user!=null">
<span>do something</span>
</s:if>
So if a user did not login,he will never see the menu of "do something".
Now I wonder how to make it in the asp.net?
Is this controled in开发者_运维问答 the xx.aspx.cs?
Thanks.
There are several ways to handle "membership" in asp.net. Microsoft has the Membership Provider as a built in solution. It seems however you have gone with a failrly simple one of your own devising.
You could handle your problem two ways using what you've already got.
In the aspx page you could have:
<% if(Session["user"] != null) { %>
<span>Do Something</span>
<% } %>
Preferably move the logic to the code behind page (.aspx.cs) In your aspx page have
<span id="thisSpan" runat="server">Do Something</span>
Then in yout code behind page in the onPage Load event
thisSpan.Visible = Session["user"] != null;
精彩评论