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.
Microsoft Dynamics CRM Consultant
Gustaf, you’re my hero! This solved my problems with databound dropdownlists in a custom asp.net webapp for CRM 4.0 🙂 Thank you!
thanks for your nice comment!
Glad to be of service!
Gustaf, I linked to your site in my blogpost : http://www.brutusonline.nl/?p=393
It’s dutch 🙂
your post solved my deployment issue w/ a custom app that makes use of viewstate – many thanks!!! 🙂