SitecorePowerShell / Console

Sitecore PowerShell Extensions
https://doc.sitecorepowershell.com/
Other
114 stars 70 forks source link

Immediate Window Error #1225

Closed gerardorm closed 3 years ago

gerardorm commented 3 years ago

Using Sitecore PowerShell Extensions 5.0.0.42513 Sitecore 9.1 Windows PowerShell 5.1

Expected Behavior

Open the Immediate window without an error.

Actual Behavior

I get this error when open the Immediate Window while debuging. image

Steps to Reproduce the Problem

Please include the version number of SPE and Sitecore.

michaellwest commented 3 years ago

Can you reproduce the issue locally with 6.2?

gerardorm commented 3 years ago

Can you reproduce the issue locally with 6.2?

I have not done it yet. I mean we prefer if we stay with 5.0, Is this something you think we should upgrade?

michaellwest commented 3 years ago

Did you remove any languages? What is unique about your client language?

gerardorm commented 3 years ago

No, we did not, we do have several languages but EN is the primary one. Seems like Context.ContentLanguage is null inside ExecuteCommand, which is weird.

Inside PSE I can call ContentLanguage. image

I did an upgrade to 5.1 I got the same issue.

image

gerardorm commented 3 years ago

Maybe using LanguageManager.DefaultLanguage instead of Context.ContentLanguage ?

gerardorm commented 3 years ago

Hi, @michaellwest I found out that the root issue first of all, the IgnoreUrlPrefixes setting value contains the path for /sitecore modules/PowerShell so this was causing some inconsistencies when calling the ExecuteCommand so basically every path that you ignore prevent Sitecore from processing specific requests, causing ASP.NET to process the request without Sitecore. But after removing that I get 401 for each call to /sitecore%20modules/PowerShell/Services/PowerShellWebService.asmx image

michaellwest commented 3 years ago

I think what you need is the patch for identity server. Are you using IS?

I believe a newer release like 5.1 came with the patch in the package.

michaellwest commented 3 years ago
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:security="http://www.sitecore.net/xmlconfig/security/">
  <sitecore role:require="Standalone or ContentManagement" security:require="Sitecore">
    <pipelines>
      <owin.cookieAuthentication.validateIdentity>
        <processor type="Sitecore.Owin.Authentication.Pipelines.CookieAuthentication.ValidateIdentity.ValidateSiteNeutralPaths, Sitecore.Owin.Authentication">
          <siteNeutralPaths hint="list">
            <!-- This entry corrects the infinite loop of ExecuteCommand in the SPE Console -->
            <path hint="spe">/sitecore%20modules/PowerShell</path>
          </siteNeutralPaths>
        </processor>
      </owin.cookieAuthentication.validateIdentity>
    </pipelines>
  </sitecore>
</configuration>
gerardorm commented 3 years ago

Since I installed SPE I added the patch, no luck so far. Thanks for your time @michaellwest, sorry for bothering you. image

michaellwest commented 3 years ago

Hey @gerardorm , not a bother at all. If you do update to 6.2 then it would be easier for me to provide you with dlls to debug the issue.

gerardorm commented 3 years ago

Hi @michaellwest, good news this morning I was able to get some luck, I added a patch for a site definition and added after 'modules_shell'. Patch: <site patch:after="*[@name='modules_shell']" name="modules_powershell" virtualFolder="/sitecore modules/PowerShell" physicalFolder="/sitecore modules/PowerShell" language="en" database="core" domain="sitecore" content="$(defaultContentDatabaseName)"/>.

Thanks for the help, if you want to remove the ticket or maybe leave it so someone can based on this if they are having the same issues.

Regards.

michaellwest commented 3 years ago

What an interesting solution. How did you figure out to try that?