web.config

You are currently browsing articles tagged web.config.

imageSo you have created some web parts and they work fine on your test machine but when you want to register them on a test or production machine you only get a uninformative ‘The virtual path could not be loaded’.

I guess you have already checked that the path is correct several times and that you have deployed all DLL’s and ASP.NET files. What is wrong?

LoadControl() parses and compiles your markup

A quick look with reflection reveals the LoadControl() is called to verify that the web part really exists. When you ask ASP.NET for a user control it will parse the ASCX-file, generate code and then compile it.

So there is a lot that can go wrong and all exceptions from this process is swallowed by the user interface and replaced with virtual path could not be loaded.

A good way to actually see the exception is to create a dummy aspx file and register all user controls and reference them from markup. When you try to view the aspx file any compilation error from the user controls will surface.

Examine compile and pages tag in your web.config

The most common reason markup works fine on one machine but not another is differences in web.config. Check the compilation and pages tag and compare them for differences between the machines.

Tags: , , , ,

EPiServer has a site tag with a lot of attributes. When you change the web.config from EPiServer Manager or by calling Save on the Configuration class yourself all attributes will be on one looong line (this is default behaivour by the dotnet framework so its not EPiServers fault).

If you put web.config under version control and would prefer if changes to singe attributes are easy to detect with a diff tool, this is not the optimal.

It is possible to change formatting in Visual Studio to get one attribute per line and that works much better for text diff tools. (This requires that you do your changes with Notepad or Visual Studio and not use EPiServer Manager or the Admin Mode to change the settings.)

Go to Tools -> Options -> Text Editor -> XML -> Formatting and select “Align attributes each on a separate line”

Click Edit -> Advanced -> Format Document (or Format Selection if you only want to adjust a part of the file) before you check in your web.config to reformat.

Voilà! Your web.config is readable!

(See also discussion in EPiServer Developer Forum)

Tags: , , ,