Problems with ViewState in aspx page residing in Virtual Directory beneith MS CRM

I have been developing a front-end user GUI for a product configurator as a normal aspx-page. I started the development localy and then moved the project to our development server in a virtual directory bellow the CRM directory. (Please read earlier posts concerning problems with this and how to handle it) This is an unsupported way of placing your custom aspx-pages, but the disadvantages of doing it any other way are to great.

Well, my code used ViewState to store some data between requests and this had worked fine on my local machine. But, when I moved it to the virtual directory bellow the CRM site, the ViewState handling stopped. I tried to override the LoadViewState-method but it was never fired. I tried to explicitly set the page to have the property EnableViewState = true, but that didn’t help either.

Then I remembered some things about how settings are inherited from the master website to all virtual directories bellow (i.e. the web.config settings are inherited). This is the reason for why you have to add some <remove assembly=”…”>tags to the virtual directory’s web.config when deploying bellow the CRM website.

I thought that there might be some swith in the CRM web.config that disabled the ViewState and there was; the tag I found was the following:

<pages buffer=”true” enablesessionstate=”false” enableviewstate=”false” validaterequest=”false”>

So, I copied the entire tag to the web.config in the virtual directory, changed enableviewstate=”true” and magic, it worked!

So, specific advice: This is why viewstate might not be working in a Virtual Directory bellow the CRM site.
General advice: All settings in a websites web.config are automatically inherited to all virtual directories bellow. If you want to change anything, set this explictly in a local copy of web.config.

Over and out.

Gustaf Westerlund
Microsoft Dynamics CRM Consultant

WM-Data/Logica CMG

ASP page LifeCycle

Currently I am working with a product configurator via an integration hub, a very interesting project that is quite complex. One part of this is to create a dynamic apsx-page that let’s the user choose properties of that are definied from the product configurator. Hence I am creating a new aspx-page that has to dynamically create lots of controls.

In order to do this properly, it is vital to understand the execution model of aspx-pages and the lifecycle of the page. I found this page that describes this, in an easy and understandable fashion. Please review it, if you are in similar needs as I.

Gustaf Westerlund
Microsoft Dynamics CRM Consultant

WM-Data/Logica CMG

Where to place your custom aspx files

Today I held another crash-course in Extending MS CRM 3 with .NET. It is a very comressed version of the MOC (Microsoft Official Curriculum) course with the same name. The attendées were 4 very sharp CRM professionals from Cybernetics and Releye. If you are interested in attending this course please contact Informator at

We were discussing the problems with kerberos double-hopp trust delegation when using a SQL RS on a different server than the CRM server. It dawned on my however that a similar problem might acctually arise if you choose to host your custom aspx-files on a separate server from the CRM-server. I am no expert at this kerberos stuff but would find it quite possible that you might get this problem. I havn’t tested this, so treat it as a hunch. If anyone has confirmation or the opposite, please comment this posting.

In short, to avoid potential problems, make sure your website for you custom websites are hosted on the same server as CRM. (please note that it is not supported to use the same website as CRM).

Gustaf Westerlund
CRM and SharePoint Consultant

Humandata AB