AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Development site url infinitely returns 302 Found and redirects to /default
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
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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?
|
|
|
|
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?
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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 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?
|
|
|
|
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?
|
|
|
|
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 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
|
|
|
|
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.
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
Development site url infinitely returns 302 Found and redirects to /default
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.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close