logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Jay  
#1 Posted : Tuesday, July 19, 2022 2:06:19 PM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
I have a 9.0.6 development site with a development site license registered to domain [server].[company].local.

The store url is https://[server].[company].local/, and I have not added anything to the routing table. That url points to a server on our internal network, it is not my PC.

If I put that store url in the browser, it gets in an infinite loop redirecting to https://[server].[company].local/default based on 302 Found responses. (Actually it is an infinite loop in theory; the browser eventually stops, warning that it has been redirected too many times.)

Each redirect causes the following error to get logged:
Code:
2022-07-19 11:29:58,934 ERROR AbleCommerce         An error has occured at https://[server].[company].local/default
System.Web.HttpException (0x80004005): Cannot redirect after HTTP headers have been sent.
   at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
   at CommerceBuilder.Essentials.ServiceabilityValidationModule.End(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

If use the debugger, the sender going to the ServiceabilityValidationModule.End function is {ASP.global_asx}. Inside the function, the sender.Response is always a 302 Found with a redirect location of "/default".

Any ideas how to fix this? It has always been this way since the initial install, and I've been getting around it by putting the /Admin path in the browser, which redirects to the Admin login page and I log in there. After I'm logged in via the admin login page, the admin and storefront both load just fine. I'm trying to start customizing some stuff, and I'd like to get this resolved.

EDIT: removed company/server info in error text

Edited by user Tuesday, July 19, 2022 4:40:29 PM(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Joe Payne2  
#2 Posted : Tuesday, July 19, 2022 3:04:18 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
You have an SSL cert configured on the IIS website hosting the store app? Most local dev installs don't run HTTPS unless somebody knows how to work with self-signed SSL certs.
Jay  
#3 Posted : Tuesday, July 19, 2022 4:31:48 PM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Yes, it is a self-signed certificate so I can test that forcing https is working. I suppose that might be related, but I have an AC Gold development server set up the same way with a self-signed certificate and it never had a problem loading the default page.

EDIT: added "loading the default page" to last sentence.

Edited by user Tuesday, July 19, 2022 4:33:22 PM(UTC)  | Reason: Not specified

Joe Payne2  
#4 Posted : Tuesday, July 19, 2022 5:40:11 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
Just a thought. Maybe switch off SSL manually in ac_storesettings, restart app pool and hit it with HTTP. See if the redirect still fires.

Also maybe try clearing all cookies for the site and hit the admin login url.

I’ve seen some oddities when the admin login user account is password-expired and the redirect to set a new password doesn’t work every time. Happens so infrequently we never bothered to address it.
Jay  
#5 Posted : Wednesday, July 20, 2022 11:29:54 AM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
I think the Error Log entries may not be relevant. In taking a fresh look at it today, I see that I only got those error log entries for each redirect on the first try. The rest of the times I tried, there were no error log entries, but it did still get stuck in the redirect loop.

I also found that even though the site url was https://..., the SSL settings page did not have SSL Redirect checked. However, I tried it with SSL Redirect checked and "Secure all pages " selected, and I got the same redirect loop (but no error log entries). I tried it with SSL Redirect checked and "Apply SSL settings as defined below" selected and the site url set to http://..., and got the same redirect loop (but not error log entries). Then I tried it without the SSL Redirect set and with the site url as http://..., and I got the same redirect loop (but no error log entries). I closed the browser and stopped and restarted IIS between each test.

Going directly to /Admin and logging in there worked fine as before.

Anyone have any other ideas?
nadeem  
#6 Posted : Friday, July 22, 2022 1:02:12 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 110

Thanks: 19 times
Was thanked: 18 time(s) in 18 post(s)
Have you tried in another browser's private window?
Jay  
#7 Posted : Friday, July 22, 2022 1:20:57 PM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
I tried it with normal and private windows in Edge, Chrome, and FireFox. All gave the same result.
nadeem  
#8 Posted : Friday, July 22, 2022 1:27:45 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 110

Thanks: 19 times
Was thanked: 18 time(s) in 18 post(s)
Couple of more things to check:

- Edit and check the home page URL from the merchant admin
- Check if there is any redirect set from Admin/SEO/FixedRedirects
- Check and confirm that the file /Website/Views/Webpage/Index.cshtml isn't modified somehow
Jay  
#9 Posted : Friday, July 22, 2022 1:56:19 PM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
I think I figured it out, but I'm not sure what the best solution is or why it is this way.

ValidatePageAttribute.OnActionExecuting(ActionExecutingContext filterContext) is getting called. The following lines:
Code:

int id = AlwaysConvert.ToInt(filterContext.RouteData.Values["Id"]);
var webpage = EntityLoader.Load<Webpage>(id);

set id to 9 and gets a webpage based on it.
In this code:
Code:

if ((webpage.Visibility == CatalogVisibility.Private) &&
(!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles)))
{
    if (!IsHomePage(webpage))
    {
        context.Response.Redirect(NavigationHelper.GetHomeUrl()); // referred to below as the redirect branch
    }
    else
    {
        context.Server.Transfer(NavigationHelper.GetHomeUrl());
    }
}
else
{
    PageVisitHelper.RegisterPageVisit(webpage.Id, CatalogNodeType.Webpage, webpage.Name);
    PageHelper.BindMetaTags(filterContext, webpage);
}

the first if evaluates to true. Therefore, IsHomePage(webpage) is called.

IsHomePage is defined as:
Code:

private bool IsHomePage(Webpage webpage)
{
    if (webpage == null) return false;
    string homePageUrl = NavigationHelper.GetHomeUrl();
    string webpageUrl = webpage.CatalogUrl;
    if (!webpageUrl.StartsWith("~/"))
        webpageUrl = "~/" + webpageUrl;
    return string.Compare(webpageUrl, homePageUrl) == 0;
}


NavigationHelper.GetHomeUrl() is hard-coded to return "~/default".
webpage.CatalogUrl returns "Default", which is prepended to be "~/Default".
So, the string.Compare returns not zero, which doesn't equal 0, so the function returns false, which causes the redirect branch of the if statement to execute in OnActionExecuting(...) shown above, and the whole process repeats.

Edited by user Friday, July 22, 2022 2:01:25 PM(UTC)  | Reason: more corrections

Jay  
#10 Posted : Friday, July 22, 2022 2:23:44 PM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: nadeem Go to Quoted Post
Couple of more things to check:

- Edit and check the home page URL from the merchant admin
- Check if there is any redirect set from Admin/SEO/FixedRedirects
- Check and confirm that the file /Website/Views/Webpage/Index.cshtml isn't modified somehow


Admin > Website > Content Pages > Home Page - Page URL is https://[server].[company].local/Default, and I can't change the "Default" part of it.
Admin/Config/SEO/FixedRedirects - none
/Website/Views/Webpage/Index.cshtml - not modified

So I guess the question is, if GetHomeUrl() is going to always return "~/default", how do I get the Home Page setting in Admin to have "default" instead of "Default" after the store URL?
nadeem  
#11 Posted : Monday, July 25, 2022 6:13:56 AM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 110

Thanks: 19 times
Was thanked: 18 time(s) in 18 post(s)
In the below code, the if statement will ONLY execute if the webpage visibility is set to PRIVATE and the current user isn't the admin user.

Code:
if ((webpage.Visibility == CatalogVisibility.Private) &&
(!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles)))
{
    if (!IsHomePage(webpage))
    {
        context.Response.Redirect(NavigationHelper.GetHomeUrl()); // referred to below as the redirect branch
    }
    else
    {
        context.Server.Transfer(NavigationHelper.GetHomeUrl());
    }
}
else
{
    PageVisitHelper.RegisterPageVisit(webpage.Id, CatalogNodeType.Webpage, webpage.Name);
    PageHelper.BindMetaTags(filterContext, webpage);
}


I am wondering if you have mistakenly changed the visibility of the Home Page webpage to Private?
Jay  
#12 Posted : Monday, July 25, 2022 8:35:39 AM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: nadeem Go to Quoted Post

I am wondering if you have mistakenly changed the visibility of the Home Page webpage to Private?


Ah, that was it. I've been spending short periods of time messing with AC 9 while mainly working on other projects. Our current AC GOLD site's Access Restriction is set to "Registered Users Only". Maybe I confused that setting with the Visibility setting, and then forgot I had changed this setting because I had to spend time working on other things. Either that, or I accidentally hit the mouse button when the cursor was over the visibility setting. That's not very likely though, because to going from Public to Private requires 2 clicks.

That does bring up the point that there's no "save" button or "are you sure" warning on the Admin > Website > Content Pages page when you click the Visibility setting. It just immediately changes the setting and the icon. If you accidentally click there and don't happen to notice the changed icon, it has the potential to create the problem I was experiencing. Is that setting something that should require confirmation, at least for the home page?

Are there any other potential problems with having GetHomeUrl() return "~\default" (lowercase d) but having the Home Page's Page URL end with "\Default" (uppercase D)?

Also, I noticed that when you change the Visibility setting, the mouse-over pop-up description doesn't change until you reload the page. I can report that in the bugs forum if you want, just let me know.

Edited by user Monday, July 25, 2022 8:50:22 AM(UTC)  | Reason: Removed references to requiring login to access the site being a customization rather than a configu

nadeem  
#13 Posted : Monday, July 25, 2022 12:08:21 PM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 110

Thanks: 19 times
Was thanked: 18 time(s) in 18 post(s)
Quote:
Are there any other potential problems with having GetHomeUrl() return "~\default" (lowercase d) but having the Home Page's Page URL end with "\Default" (uppercase D)?


I don't think so because the code is only here. This will always result in the home page not being matched. For other pages, it will redirect to home if visibility is set to Private. But the code needs to be fixed to ignore the case in comparison like this:

Code:
return string.Compare(webpageUrl, homePageUrl, System.StringComparison.OrdinalIgnoreCase) == 0;


The else part of the code also not needed

Code:
else
{
     context.Server.Transfer(NavigationHelper.GetHomeUrl());
}


OR is need to be fixed to


Code:
else
{
     context.RewritePath(NavigationHelper.GetHomeUrl());
}


Quote:
Also, I noticed that when you change the Visibility setting, the mouse-over pop-up description doesn't change until you reload the page. I can report that in the bugs forum if you want, just let me know.


I have registered a bug report to take care of these issues in a future release. I think we don't need to allow changing the Visibility for Home Page.
Users browsing this topic
Guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.