Build a Sitecore admin page with a Sitecore 10.1.0 Helix Project Setup

 Install Sitecore.Client nuget package:


Note that Sitecore.Client 10.1.0 is based on .net framework 4.8. So, ensure that your Visual Studio project targets the concerned framework -


Build is successful:


When you cross-check, you can see the latest package references added, I better set copy local to false for all dlls in order to forego dll overwrite issues during VS project publish:


Since Sitecore.Client package is referenced, you can add the namespaces:


Since I want to create an admin page, I inherit from AdminPage class. Now, I can use the CheckSecurity method in the page load event handler:


After I build and publish to the bin folder and dotpeek the dll, I can see that the changes are effected:


All good so far, let me try to access my shiny new page without logging into Sitecore and see if  it asks me to authenticate.

Before that, since I'm a developer, I want to see the breakpoint being hit so, don't forget to publish with the debug flag set in the Visual 2022 IDE:



Attach to the website's w3wp process, access the page after setting the breakpoint in the page load event handler and if everything goes fine, you must first get the login page:




After login, you must see the application stopping at the breakpoint :



Then, you get to  see the page:




Here is the sln explorer for my newly created helix project:





Comments

Popular Posts