Try our conversational search powered by Generative AI!

Allan Thraen
Nov 1, 2009
  14936
(5 votes)

QuickWatch Gadget

Here is my humble contribution to the Gadget Contest 2009. The SiteCenter in EPiServer CMS 6 is truly awesome and I think it will be a big help to many of the roles involved in a company’s web site – editors, web masters, marketing managers, sales people, managers, designers and my favorite group: developers.

So naturally I made a gadget for them. A gadget that I hope can make life a little bit easier for all the brave developers who are on the front lines in the fight for awesome functionality in tomorrows Web. (If I sound a bit too bombastic, I apologize – living in the US is affecting me in ways I don’t even dare to think about).

Nevertheless, the QuickWatch Gadget is a gadget that allows you to write c# code directly in the gadget, compile it on-the-fly, run it in the current AppDomain and context and then browse whatever object structure your code returns.

A simple example:

image

In the above example the code line we wrote is being executed, and an implicit “return” is inserted before the statement, since it isn’t already there. But of course we could expand on it:

image

What is happening behind the scenes is that a temporary method is being created, and the code is executed inside that.

- “That’s all fine and nice – but I don’t need yet another calculator”, I hear you cry. Well, that’s where it comes in handy that it’s running in the same AppDomain and context as the current web site. You can access pretty much anything – almost like when you use the “QuickWatch” while debugging in Visual Studio.

How about this:

image

You can drill-down in the object structure, by clicking on each line. Or what about browsing through the Current Http Context? Or perhaps registering a new PageProvider dynamically? As I was developing this, I actually used it to debug it self. And once you’ve gotten hooked on dynamic code execution, there’s no turning back :-)

You can of course configure which namespaces to use, how deep to dig the object tree, and so on if the “Edit” view:

image

In this view you can also specify a number of values you want to constantly watch – and you can even turn off the custom code box if you only want to use the gadget to monitor certain values – like a counter for numbers of items in your data store:

image

“Great, I can see it’s useful – but wouldn’t this be a security problem?  Somewhere, Bruce Schneier must be weeping.”

Every single line of code ever written is in my eyes a potential security problem. This shouldn’t stop us from writing code and exploring the options that lie before us. I have tried to secure the gadget as good as I could – for instance it checks to make sure only Administrators use it. But if you are working for the Pentagon, you might want to hold back deploying it to all production servers unless there is an urgent need :-) However I see no problem using it on development and test environments. It safes you the trouble of attaching a debugger :-)

Download & Installation

Inspired by Björns cool gadget I have also made a zip-module that can easily be installed using EPiServer Deployment Center on an existing CMS 6 CTP 2 instance.

Download it here.

You can also get the full source here.

 

Bugs and feature requests

There is a small number of known bugs – some of the related to the fact that ASP.NET likes to modify whatever content is submitted. Also, a feature I am considering adding is the ability to work with any .NET language – not just C# in it. If you have further bugs or feature requests send them to ath (at) episerver.

Nov 01, 2009

Comments

Sep 21, 2010 10:32 AM

I think I might actually use this. Awesome gadget
/ Jacob Khan

Sep 21, 2010 10:32 AM

Really nice gadget, Allan!

Sep 21, 2010 10:32 AM

Allan, that is the dogs b******S.
/ Paul Smith

Sep 21, 2010 10:32 AM

Code and download is now also available as a codeplex project. Next step is to migrate it back to CMS 5, so it can be used as an Admin mode tool.
Check out the Codeplex project: http://quickwatchgadget.codeplex.com/

Sep 21, 2010 10:32 AM

Now this is some cool stuff, very nice indeed Allan!
/ Fredrik Josefsson

Sep 21, 2010 10:32 AM

Great one!

Sep 21, 2010 10:32 AM

Just a quick poll - would anyone be interested in a back-port of this gadget to EPiServer CMS 5 as an admin mode plugin?
/ Allan

Sep 21, 2010 10:32 AM

Interesting idea! Might be very useful for support cases analysis on the customer's server.

Please login to comment.
Latest blogs
The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024

What's new in Language Manager 5.3.0

In Language Manager (LM) version 5.2.0, we added an option in appsettings.json called TranslateOrCopyContentAreaChildrenBlockForTypes . It does...

Quoc Anh Nguyen | Apr 15, 2024

Optimizely Search & Navigation: Boosting in Unified Search

In the Optimizely Search & Navigation admin view, administrators can set a certain weight of different properties (title, content, summary, or...

Tung Tran | Apr 15, 2024

Optimizely CMS – Getting all content of a specific property with a simple SQL script

When you need to retrieve all content of a specific property from a Page/Block type, normally you will use the IContentLoader or IContentRepository...

Tung Tran | Apr 15, 2024

Join the Content Recommendations Work Smarter webinar May 8th 16.00-16.45 CET with expert Aidan Swain

Learn more about Content Recommendations, with Optimizely’s very own Senior Solutions consultant, Aidan Swain . He will discuss best practices and...

Karen McDougall | Apr 12, 2024