HotcakesCommerce / hotcakes-commerce-core

The core of the e-commerce part of the overall solution. This is an ecommerce shopping cart solution built on top of the DNN (DotNetNuke) CMS. Anyone can do commerce online now!
https://mmmcommerce.com
MIT License
69 stars 55 forks source link

UrlRewrite: Server cannot append header after HTTP headers have been sent #219

Closed Navilois closed 3 years ago

Navilois commented 4 years ago

Describe the bug

Directly related to #112 When the alternative PageUrl of a product (in this case the uppercase url "GR33L") is requested, the exception "Server cannot modify cookies after HTTP headers have been sent." is thrown once Hotcakes.

Software Versions

To Reproduce

Steps to reproduce the behavior:

  1. Edit a product and set another Page URL
  2. Clear caches and request the old Page URL (301)
  3. Check Admin Logs
  4. See error

Expected behavior

Do a clean 301, set whatever cookies necessary

Actual behavior

Does a 301, but throws exception and doesn't modify cookies (most likely)

Error log

10/22/2019 13:15:52 Hotcakes Exception Sierzega Severity Error AssemblyVersion 3.2.1 PortalID 0 PortalName Sierzega UserID Severity:Error AssemblyVersion:3.2.1 PortalID:0 PortalName:Sierzega UserID: UserName: ActiveTabID:92 ActiveTabName:Product Viewer RawURL:/en-us/Products/Product-Viewer/GR33L AbsoluteURL:/Default.aspx AbsoluteURLReferrer: UserAgent:Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0 DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke ExceptionGUID:593cde48-18bd-49da-830b-87936522039b InnerException:Server cannot modify cookies after HTTP headers have been sent. FileName: FileLineNumber:0 FileColumnNumber:0 Method:System.Web.HttpResponse.BeforeCookieCollectionChange StackTrace: Message: System.Web.HttpException (0x80004005): Server cannot modify cookies after HTTP headers have been sent. at System.Web.HttpResponse.BeforeCookieCollectionChange() at System.Web.HttpCookieCollection.Add(HttpCookie cookie) at Hotcakes.Commerce.SessionManager.SetCookieString(String cookieName, String value, Nullable`1 expirationDate, Boolean secure) Source:

Navilois commented 4 years ago

Additional Logs of the live server (DNN 09.03.02, Hotcakes 03.02.00). Usually a Hotcakes exception followed by a DNN exception:

10/22/2019 12:28:43 Hotcakes Exception

Sierzega Severity Error AssemblyVersion 3.2.0 PortalID 0 PortalName Sierzega UserID Severity:Error AssemblyVersion:3.2.0 PortalID:0 PortalName:Sierzega UserID:-1 UserName: ActiveTabID:92 ActiveTabName:Product Viewer RawURL:/en-us/Products/Product-Viewer/GR33L AbsoluteURL:/Default.aspx AbsoluteURLReferrer: UserAgent:Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke ExceptionGUID:826b3daa-cf93-4986-aca6-0c7a3e35a718 InnerException:Server cannot modify cookies after HTTP headers have been sent. FileName: FileLineNumber:0 FileColumnNumber:0 Method:System.Web.HttpCookieCollection.Add StackTrace: Message: System.Web.HttpException (0x80004005): Server cannot modify cookies after HTTP headers have been sent. at System.Web.HttpCookieCollection.Add(HttpCookie cookie) at Hotcakes.Commerce.SessionManager.SetCookieString(String cookieName, String value, Nullable`1 expirationDate, Boolean secure) Source:

10/22/2019 12:28:44 Page Load Exception

Sierzega AbsoluteURL /Default.aspx DefaultDataProvider DotNetNuke.Data.SqlDataProvi AbsoluteURL:/Default.aspx DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke ExceptionGUID:77821b91-1e1a-4c2e-9794-0e388e516bee AssemblyVersion: PortalId:-1 UserId:-1 TabId:-1 RawUrl: Referrer: UserAgent: ExceptionHash:okiGYRPhenUZgy2cXP624B2BD9k= Message:Server cannot modify cookies after HTTP headers have been sent. StackTrace: InnerMessage:Server cannot modify cookies after HTTP headers have been sent. InnerStackTrace: at System.Web.HttpCookieCollection.Set(HttpCookie cookie) at System.Web.Helpers.AntiXsrf.AntiForgeryWorker.GetFormInputElement(HttpContextBase httpContext) at System.Web.Helpers.AntiForgery.GetHtml() at DotNetNuke.Framework.ServicesFrameworkImpl.RegisterAjaxAntiForgery(Page page) at DotNetNuke.Framework.PageBase.OnPreRender(EventArgs e) at DotNetNuke.Framework.DefaultPage.OnPreRender(EventArgs evt) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Source: FileName: FileLineNumber:0 FileColumnNumber:0 Method:

WillStrohl commented 4 years ago

Thank you for reporting this. This is a duplicate issue, though. :)

Please see issue #112

Navilois commented 4 years ago

I just tested it on 03.02.02, the issues still exists. Quoting you from #112:

This has been confirmed to be resolved in the pending 03.02.02 release, but only during checkout. There is another instance that may occur, but it hasn't yet been determined when/how.

Can we reopen one of the two issues?

Current log:

11/07/2019 10:17:15 Hotcakes Exception xxx Sierzega Severity Error AssemblyVersion 3.2.2 PortalID 0 PortalName Sierzega UserID Severity:Error AssemblyVersion:3.2.2 PortalID:0 PortalName:Sierzega UserID: UserName: ActiveTabID:92 ActiveTabName:Product Viewer RawURL:/en-us/Products/Product-Viewer/GR33L AbsoluteURL:/Default.aspx AbsoluteURLReferrer: UserAgent:Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0 DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke ExceptionGUID:53c1ecfc-22e7-4e7b-96c0-ff901a4279d4 InnerException:Server cannot modify cookies after HTTP headers have been sent. FileName: FileLineNumber:0 FileColumnNumber:0 Method:System.Web.HttpResponse.BeforeCookieCollectionChange StackTrace: Message: System.Web.HttpException (0x80004005): Server cannot modify cookies after HTTP headers have been sent. at System.Web.HttpResponse.BeforeCookieCollectionChange() at System.Web.HttpCookieCollection.Add(HttpCookie cookie) at Hotcakes.Commerce.SessionManager.SetCookieString(String cookieName, String value, Nullable`1 expirationDate, Boolean secure) Source:

WillStrohl commented 4 years ago

Oh, I see. You're right. The error was only fixed during checkout. Sorry about that. :)