Understanding the UniqueId property in an ASP.NET MVC filter context
Posted: (EET/GMT+2)
When working especially with ASP.NET MVC action filters and their associated ActionExecutingContext objects, you might have noticed that there's something called the UniqueId in these context objects. More specifically, if you access the ActionDescriptor and onwards to the ControllerDescriptor object, you will finally find a string property called UniqueId.
Its value is something like this:
[24]cd73190b-ab9d-384c-8315-10ff295c572a[5]33554721[2]Home[24]3ff401af- 3807-4458-8953-e2d812c10658[8]11446742
What does this UniqueId mean and how it is used? You can use the UniqueId value to uniquely identify a controller within your application. The string consists of the type of the controller, the name of the controller, and also the module where the controller is. The format of the string is "[n]data", where [n] is the length of the data string and data the actual data, such as a GUID-like value.
If you are looking at the ASP.NET MVC source code, the relevant source files are DescriptorUtil.cs and ControllerDescriptor.cs.
Good to go, MVC!