Kentico Upgrade 8.1 to 8.2 Error Image load on Page with Macros!

Werner M asked on March 28, 2019 15:36

Hello Guys,

i am new in Kentico development. My problem is i should upgrade Kentico 8.1 to kentico 8.2. I carried out the upgrade step for step how in the documentation of Kentico 8.2. But after update i can no load image from the database. My code is <img src="~/getattachment/{%FirstPicture%}" under kentico 8.1 no Problem but after upgrade i becomme a 500 error.

The generated code on the page <img src = "/ getattachment / 88512c8f-aaf4-48fa-950e-e883daed1331" and under Kentico 8.1 no problem.

Gives it other methode to get a image from pagetyp with macros???

Initial situation I have a page type in which a picture is saved in the database. This can be uploaded to the Form tab.

The image is displayed on the page using the web part Static HTML. It must be executed by means of macro commands an image tag

Thanks for your help and ideas.

Recent Answers


David te Kloese answered on March 28, 2019 15:42

Any information in the Kentico Event Log about the error?

Perhaps you need to resign macros although that usually gives a different error: docs.kentico.com/k8/...#Workingwithmacrosignatures-Re-signingmacros

0 votesVote for this answer Mark as a Correct answer

Werner M answered on March 28, 2019 16:13

Hello David te Kloese

Thank for your help.

The info out of the conlsole is

Source: Application_Error Event code: PAGENOTFOUND User ID: 65 User name: public IP address: ::1 Description: Machine name: WERNERM Event URL: /getattachment/88512c8f-aaf4-48fa-950e-e883daed1331 URL referrer: http://localhost:1470/special-pages/precheckout/kyc.aspx

If your application uses a custom hash salt, enter the original value of the CMSHashStringSalt web.config key.

If the original hash salt was a connection string, enter the value in format: Persist Security Info=False;database=DBName;server=ServerName;user id=DBUser;password=pwd;Current Language=English;Connection Timeout=240;

Where can i set this settings? I has in Backen tool in the system application by the macros Signatures old Slat Sign all macros activiert, but where can set the settings the CMSHashStringSalt in the web.config(is this the DB connection?)

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 29, 2019 10:10

Ah! yes... so for security reasons macro's can have a signature as explained in the documentation:

docs.kentico.com/k82/.../working-with-macro-signatures

By default, new instances of Kentico use a randomly generated GUID as the hash salt. The installer sets the custom salt value through the CMSHashStringSalt key in the appSettings section of the web.config file. Instances without this web.config key use the application's main database connection string as the salt (the exact CMSConnectionString value in the web.config file)

It seems you either changed a value in the salt or user. Best thing would be to just resign all macro's.

docs.kentico.com/k82/...Workingwithmacrosignatures-Re-signingmacros

This will update all signatures based on your current user and salt.

Go to the signatures sub menu item in the System application and check the sign all macros checkbox, and hit update macro signatures. This will go over all objects in Kentico to update the signatures, so it might take a while. Image Text

1 votesVote for this answer Mark as a Correct answer

Werner M answered on March 29, 2019 13:44

thanks for your detailed description. I have upgrade the signature. But the the page load without image but with text load.

Is there any other way to load the images with macros except with <img src = "~ / getattachment / {% FirstPicture%}" ??

The page is loaded with the text but in the pictures I get a 500 er error.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 29, 2019 13:59

Can you confirm the actual attachment is there on that page?

https://content.screencast.com/users/DavidTK/folders/Jing/media/ae8fc2ca-49c7-4d4e-8fed-55cd17afa826/2019-03-29_1357.png

can you view/change it?

You mentioned a 500 error, is the error in the Event Log still the same?

1 votesVote for this answer Mark as a Correct answer

Werner M answered on March 29, 2019 15:11 (last edited on March 29, 2019 15:12)

I have the picture not in the attachments but in the From tab of the bage. If I click on it, I will also see the correct file.

The 500 error is in the console of the browser.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 29, 2019 15:15

Can you check and share the Kentico Event log message/details:

Image Text

1 votesVote for this answer Mark as a Correct answer

Werner M answered on March 29, 2019 15:33

Message: Error executing child request for handler 'ASP.cmstemplates_xxx_contenttemplate_aspx'.

Exception type: System.Web.HttpException Stack Trace: at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) at System.Web.HttpServerUtility.Transfer(IHttpHandler handler, Boolean preserveForm) at CMS.URLRewritingEngine.URLRewriter.TransferPageNotFoundInternal(String path, Boolean useRewrite, Boolean statusCodeValid) at CMS.URLRewritingEngine.URLRewriter.RedirectToPageNotFound(SiteNameOnDemand siteName, ViewModeOnDemand viewMode, Boolean alwaysRedirect) at CMS.URLRewritingEngine.URLRewriter.HandlePageNotFound() at CMS.URLRewritingEngine.URLRewritingHandlers.HandlePageNotFound(Object sender, EventArgs e) at CMS.Base.AbstractHandler.CallEventHandler[TArgs](EventHandler1 h, TArgs e) at CMS.Base.AbstractHandler.Raise[TArgs](String partName, List1 list, TArgs e, Boolean important) at CMS.Base.SimpleHandler2.RaiseExecute(TArgs e) at CMS.Base.SimpleHandler2.RaiseExecute(TArgs e) at CMS.Base.SimpleHandler`2.StartEvent(TArgs e) at CMS.Base.ApplicationModule.EndRequest(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)

Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.

Exception type: System.Web.HttpUnhandledException Stack Trace: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.cmstemplates_baonlineselling_contenttemplate_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\c7465094\2f7dc587\App_Web_contenttemplate.aspx.e85c17ac.1eg5vses.0.cs:line 0 at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)

Message: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.

Exception type: System.Web.HttpException Stack Trace: at System.Web.UI.Page.get_Session() at CMSWebParts_xxxx_MMT_MMTParameterView.OnInit(EventArgs e) in e:\wwwroot\xxx\CMSWebParts\xxx\MMT\MMTParameterView.ascx.cs:line 51 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Machine name: xxx Event URL: /getattachment/88512c8f-aaf4-48fa-950e-e883daed1331 URL referrer: http://xxxx/xxx/precheckout/kyc.aspx

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 29, 2019 15:49

Can you compare you're web.config between the 8.1 and current 8.2 version in relation to the following error:

    Message: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.

Can you check what logic is being done in that custom webpart:

Exception type: System.Web.HttpException Stack Trace:
at System.Web.UI.Page.get_Session()    
at CMSWebParts_xxxx_MMT_MMTParameterView.OnInit(EventArgs e)
in e:\wwwroot\xxx\CMSWebParts\xxx\MMT\MMTParameterView.ascx.cs:line 51 <<<<<<<<<<<<
1 votesVote for this answer Mark as a Correct answer

Werner M answered on March 29, 2019 16:02 (last edited on March 29, 2019 16:03)

I added the date attribute in the web.config bim pages tag. But under 8.1 this was not necessary I added it only now after the upgrade.

I did not change the code lines from 8 to 8.2, the lines are still the same. It also throws me only on the side of a mistake in the other not

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on March 29, 2019 16:05

I'm still not sure how it tied to the macro. The page renders fine without any logged error (console and event log) if you remove the macro?

1 votesVote for this answer Mark as a Correct answer

Werner M answered on March 29, 2019 16:20 (last edited on December 10, 2019 02:31)

The view in the backend Tool.

Image Text

This is the Macro code

  {% if (TwoText != string.empty && TwoPicture != string.empty ) { %}
        <div class="w33 display-inlineblock padding-bottom-large va-top" data-balance="true">
          <img src="~/getattachment/{%TwoPicture%}" class="margin-bottom-big require-img" />
          <div class="content-txt">
            {%TwoText%}
            {%if (TwoInfo != string.Empty) { %}
            <span class="icon-info form-info form-tooltip"></span>
            <span class="infoText clearfix hidden">{%TwoInfo%}</span>
            {% } %}
          </div>
        </div>
        {% } |(identity)GlobalAdministrator%}

This is teh Page view Image Text

if the macros should not work why the text is read out and the pictures are not.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.