The web.config in Sitecore 9+ CM and CD Isn't The Same? Wait, WHAT?!?
Tags: sitecore
Published: 2020-08-17 13:52:23

So yeah, I had an education over the weekend. I figured the web.configs for xConnect sites were different, but I've always assumed it's the same for a CM and CD site. And I think in Sitecore 8 and lower, it might have been. But something changed on the way to Sitecore 9 that I'd never noticed, and I'm not just talking about the roles to define a CM and CD here.

*Full credit here to [Vincenzo Lui](https://twitter.com/VincenzoLuigi) and [Anders Laub](https://twitter.com/AndersLaub) on Sitecore Slack for this knowledge.*

So I downloaded the XP1 packages for 9.3, broke them open, and pulled out the out of the box web.configs for both, then fired up my trusty WinMerge. Not that I doubted them, but they were right! Good news is, the changes aren't huge, but they should be accounted for certainly.

So excepting out the role difference, which is obvious, here's some screenshots of what to look for. The CM configuration is on the left, and the CD configuration is on the right.

![Telerik Keys](https://dev-to-uploads.s3.amazonaws.com/i/fjfe8hxg6b87hmxmxokh.png)
<figcaption>This is also odd because the CM web.config duplicates these three settings. Lingering bugaboo I guess...</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rliyyn4tjguhpjicitnl.png)
<figcaption>In the CD setup, we're allowing access specifically to these paths. You'll see why in a minute.</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y0be73t6q75osc7ha95k.png)
<figcaption>In this `MediaRequestSessionModule` call, the CM uses "Sitecore.Analytics.Media.MediaRequestSessionModule, Sitecore.Analytics" while the CD uses Sitecore.Analytics.RobotDetection.Media.MediaRequestSessionModule, Sitecore.Analytics.RobotDetection". Use the "name" value to key any transform, it's the same in both (MediaRequestSessionModule).</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pbxidsu3j1u5tt702sb4.png)
<figcaption>With the Telerik keys gone, this makes sense, and Telerik is really only used in the authoring environment anyway.</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3awwajb3x2n9gh3ris7g.png)
<figcaption>This URL rewrite section only exists on the CM.</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9bl7sgproejpcuaodmoc.png)
<figcaption>On the CM, anonymous users can't access the "/sitecore/shell" and "/sitecore/admin" areas. On the CD, no one can access anything under "/sitecore" with the exceptions being the earlier defined items.</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sn64sfgwav72tx4zg50x.png)
<figcaption>These three location areas only exist on the CM.</figcaption>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oeuv9w0p67q4h0lpbppi.png)
<figcaption>Only on CD is there a further definition of the authentication node.</figcaption>

So there you have it. I'd recommend doing this comparison on whatever version of Sitecore you're on, at least starting from 9.0. Your best bet would be to set up a CI/CD process where the base web.configs are never touched by developers, and you're just using transforms to do the work.

But that's another blog...stay tuned!