stay on page when logging in
stay on page when logging in
On trainsignal.com when a user is on a products page and logs in, they get redirected back to the home page. Is there any way that a user can remain in the page they logged in on?
Re: stay on page when logging in
You can try following trick, first create a user control under ConLib/Custom folder
Then edit your header scriptlet and locate following code
and update it [[ConLib:Custom\LoginUtil]]
Code: Select all
<%@ Control Language="C#" ClassName="LoginUtil" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
LoginURL.Visible = Token.Instance.User.IsAnonymous;
LogoutURL.Visible = !Token.Instance.User.IsAnonymous;
}
protected void LoginURL_Click(object sender, EventArgs e)
{
if(Request.Url.AbsoluteUri.ToLower().Contains("product.aspx"))
{
Product product = ProductDataSource.Load(PageHelper.GetProductId());
if(product != null)
Response.Redirect(string.Format("Login.aspx?ReturnUrl={0}", product.NavigateUrl));
}
Response.Redirect("Login.aspx");
}
</script>
<asp:LinkButton ID="LoginURL" runat="server" CssClass="login" onclick="LoginURL_Click">Login</asp:LinkButton>
<asp:HyperLink ID="LogoutURL" runat="server" CssClass="login" NavigateUrl="~/Logout.aspx">Logout</asp:HyperLink>
Code: Select all
#if($customer.IsAnonymous)
<a href="~/Login.aspx" class="login">Login</a>
#else
<a href="~/Logout.aspx" class="login">Logout</a>
#end
Re: stay on page when logging in
Thank you for the help, I could be wrong but it seems that this solution will only work if you are on a product page, am I correct? I was hoping that I could get something working on any page on the entire site, such as the product categories or some of the custom content pages.
Re: stay on page when logging in
For any page try by updating LoginURL_Click to
Code: Select all
protected void LoginURL_Click(object sender, EventArgs e)
{
Response.Redirect(string.Format("Login.aspx?ReturnUrl={0}", Request.Url.AbsoluteUri.ToString()));
}
Re: stay on page when logging in
Works like a charm.
I kindly thank you sir
I kindly thank you sir
- mfreeze
- Commodore (COMO)
- Posts: 421
- Joined: Mon Jan 24, 2005 2:07 pm
- Location: Washington, NJ
- Contact:
Re: stay on page when logging in
In onepagecheckout.ascx.cs, can I replace the returnurl in the following lines to what you specified in this post ReturnUrl={0}", Request.Url.AbsoluteUri.ToString()));? This is release 7.0.3.
And what about login.aspx which returns the user to the last page only in admin. I find the following code in login.aspx.
and the following in logindialog.ascx.cs.
If I change login.aspx will it always return the user to the page they were on no matter what it was?
Code: Select all
if (editBilling && isAnonymous)
{
LoginPanel.Visible = true;
LoginLink.NavigateUrl = "~/Login.aspx?ReturnUrl=" + Server.UrlEncode(Request.Url.AbsolutePath);
}
Code: Select all
protected void Page_Init(object sender, EventArgs e)
{
string returnUrl = NavigationHelper.GetReturnUrl(string.Empty);
if (!string.IsNullOrEmpty(returnUrl))
{
if (returnUrl.ToLowerInvariant().Contains("/admin/"))
{
Response.Redirect(NavigationHelper.GetAdminUrl("Login.aspx?ReturnUrl=" + Server.UrlEncode(returnUrl)));
}
}
}
Code: Select all
private bool _EnableAdminRememberMe = true;
public bool EnableAdminRememberMe
{
get { return _EnableAdminRememberMe; }
set { _EnableAdminRememberMe = value; }
}
Mary E Freeze
Freeze Frame Graphics
Web Hosting and Design, ASP and CFMX Development
http://www.ffgraphics.com
Freeze Frame Graphics
Web Hosting and Design, ASP and CFMX Development
http://www.ffgraphics.com