Have you checked Request.IsAuthenticated returns true or false. If it returns true then it will only display user name. Write the below code without if condition and then check whether it displays or not: Welcome <b><%: ViewData["Name"] %></b>!
Hi, Could you explain me where you have store the user information either in Membership or database. If you are using Membership to store user information, you can refer demo application provided by mvc in visual studio. If you are using database, you can build your own logic to authenticate user. If not able to understand paste your code here... Thanks.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
how to validate validations whether textbox is empty or not. using linq to sql.
Write the below code without if condition and then check whether it displays or not:
Welcome <b><%: ViewData["Name"] %></b>!
and my .ascx
if (Request.IsAuthenticated) {
%>
Welcome <b><%: ViewData["Name"] %></b>!
<%: Html.ActionLink("Log Off", "LogOff", "Account") %>
<%
}
not display the username and also no error
ViewBag.UserName="assign user name";
then display it:
how you set set Request.IsAuthenticated to true when you are using database as a medium to store data?
Hi Rohith,
I want display in master page.
if (Request.IsAuthenticated) {
%>
Welcome <b><%: Page.User.Identity.Name %></b>!
<%: Html.ActionLink("Log Off", "LogOff", "Account") %>
<%
}
Model
Controller
Recently i added the FormsAuthentication.SetAuthCookie(model.EmailId, true); Now it is working fine.
Could you explain me where you have store the user information either in Membership or database.
If you are using Membership to store user information, you can refer demo application provided by mvc in visual studio.
If you are using database, you can build your own logic to authenticate user.
If not able to understand paste your code here...
Thanks.