Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I need to read membertype from username. Till now, I use this code, but I don't like that I need to read data from two class as Membership and Member.
Is it possible to read data from one class?
@{
var isSubmitLogin = (IsPost && Request["submit"]=="login");
var isSubmitLogout = (IsPost && Request["submit"]=="logout");
var currentUser = Membership.GetUser();
var currentMember = Member.GetCurrentMember();
var requestedUrl = Request.Url.PathAndQuery.ToString(); // Model.Url;
if (Request["ReturnUrl"]!=null) {
requestedUrl = Request["ReturnUrl"];
}
if (currentUser!=null)
{
if (!isSubmitLogout)
@Message("Logged in : " + currentUser.UserName)
@LogoutForm()
if (currentMember!=null)
if(@currentMember.ContentType.Alias.ToString()=="Customer")
Response.Redirect("/");
Response.Redirect("/my-zone");
else
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
if (currentUser==null)
if (!isSubmitLogin)
@LoginForm()
string username=Request["username"];
string password=Request["password"];
if (Membership.ValidateUser(username, password))
// RedirectFromLoginPage does not work that good within the Umbraco context
// FormsAuthentication.RedirectFromLoginPage(username, true);
FormsAuthentication.SetAuthCookie(username, true);
// Redirect to / refresh the requested page
Response.Redirect(requestedUrl);
@Message("Login failed for " + username)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Membership and Member: How retrieve info using one class?
I need to read membertype from username. Till now, I use this code, but I don't like that I need to read data from two class as Membership and Member.
Is it possible to read data from one class?
@{
var isSubmitLogin = (IsPost && Request["submit"]=="login");
var isSubmitLogout = (IsPost && Request["submit"]=="logout");
var currentUser = Membership.GetUser();
var currentMember = Member.GetCurrentMember();
var requestedUrl = Request.Url.PathAndQuery.ToString(); // Model.Url;
if (Request["ReturnUrl"]!=null) {
requestedUrl = Request["ReturnUrl"];
}
if (currentUser!=null)
{
if (!isSubmitLogout)
{
@Message("Logged in : " + currentUser.UserName)
@LogoutForm()
if (currentMember!=null)
{
if(@currentMember.ContentType.Alias.ToString()=="Customer")
{
Response.Redirect("/");
}
}
Response.Redirect("/my-zone");
}
else
{
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}
}
if (currentUser==null)
{
if (!isSubmitLogin)
{
@LoginForm()
}
else
{
string username=Request["username"];
string password=Request["password"];
if (Membership.ValidateUser(username, password))
{
// RedirectFromLoginPage does not work that good within the Umbraco context
// FormsAuthentication.RedirectFromLoginPage(username, true);
FormsAuthentication.SetAuthCookie(username, true);
// Redirect to / refresh the requested page
Response.Redirect(requestedUrl);
}
else
{
@Message("Login failed for " + username)
@LoginForm()
}
}
}
}
is working on a reply...