I see some very interesting and useful properties in the DXA WebRequestContext class. Are these documented anywhere? What properties are most commonly used and in what context? I'm also curious about the 'IsDeveloperMode' and 'Localization' properties.

I see there's a helpful page to view the Localization object from Jan Horsman here: https://community.sdl.com/solutions/content-management/tridion/tridion-developer/b/weblog/posts/inspect-the-dxa-localization-object


They are documented, right there in the code, note the XML documentation comments (the lines starting with /// ;o):


Now true, the documentation can still be improved quite a bit, but I think most of them are reasonably clear, like:

/// <summary>
/// True if the request is for localhost domain
/// </summary>
public static bool IsDeveloperMode

So if you are running a debug session from Visual Studio, your development server is typically http://localhost:31544/, and the property IsDeveloperMode will be true on any requests coming from a http://localhost URL.

/// <summary>
/// The current request localization
/// </summary>
public static Localization Localization

Localization is a bit more complex, it however points to a class, (which if you have all the source code in Visual Studio, should be easy to find). Take a look at https://github.com/sdl/dxa-web-application-dotnet/blob/master/Sdl.Web.Common/Configuration/Localization.cs

This basically is a container for the Publication information the request is made on (gathered from the URL). And since a Publication is a site, in a specific language, it is called a localization, and not just a Publication (DXA uses strongly typed models, not the CMS domain model).

Note that if you want to figure out how DXA is working internally, it absolutely makes a lot of sense to try to build it from the source code and running a debug in Visual Studio. But even just loading all the source code in Visual Studio will help you to jump from the code into the classes used there etc. And feel free to suggest aditional documentation (preferaly in XML doc comments) as a pull request to things which we haven't made clear enough (or just log an issue if you can't figure it out).

  • 4
    I've found this to be the best way to learn how it works in detail. It's actually a good thing that reading the source is the docs in some ways! And that it's possible at all without resorting to decompilers (not that I have ever done that). May 4 '17 at 15:31
  • Can you give a practical example of where and why we'd use 'IsDeveloperMode'? I guess I was more hoping for an explanation of Why it is there, rather than 'This is the Localization object'.
    – robrtc
    May 4 '17 at 17:30
  • 3
    The DXA uses IsDeveloperMode to show more detailed error information when something goes wrong rendering a region or entity view - this can help to more quickly determine the problem when developing.
    – Will Price
    May 4 '17 at 19:53
  • IMHO a framework user should not have to read the source code to be able to understand what the API can do and how the individual method calls should be used. We should have API documentation to explain the intended use of the framework. Personally I am very interested in how DXA framework works and I indeed read the code to learn more about the inner workings.
    – Jan H
    May 15 '17 at 7:47
  • The way it is currently documented it should be relatively easy to generate API documentation, but I didn't see anybody do it yet, so I'm still wondering if it's realy a need or more a convenience thing. May 15 '17 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.