Answered by:
Using Session State in custom aspx page deployed in virtual directory under CrmWeb/ISV

Question
-
Hi!
I have a problem with an web application that must be accessible via IFD. The web app creates an excel spreadsheet from a template with CRM data, and let the user download it
Environment: Windows Server 2003, IIS 6.
Because of the IFD requirement i have to deploy it just as virtual directory, and not as an application. So my web app inherits the settings from CRMs web.config in which the session state and the viewstate are disabled.
When i modify my own web.config to enable session state i get an error because my app is not an application in IIS, it's just an virtual directory...
Here the lines i added to my web.config:
<pages enableSessionState="true" /> <httpModules> <clear/> <add name="Session" type="System.Web.SessionState.SessionStateModule"/> </httpModules> <!-- Enable in-process session state for application --> <sessionState mode="InProc" cookieless="false" timeout="20"/>
Here the error message from ASP.net configuration when i click on the "State Management" tab
An error has occured attempting to read the configuration. The error message is:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source File:C:\Inetpub\wwwroot\ISV\AcpAddons\SSP\web.config
Line:30
This sounds to me that i can't use the session state functionality without deploing my webpage as application in IIS.
So here the question: can i deploy my webpage as application in IIS without the lost of IFD accessibility? (I guess not...) Or is there any Workaround?
And here the cause why i need the session state, i know it's not related to CRM 4.0 but maybe somone can help me. (It would also solve the first problem :-))
To let the user download the file i have to create the excel file on disk on the server and then redirect to it from my web page to prompt the download dialog. (Response.WriteBinary() doesn't work for me because IE6-8 won't let me download office files over https protocol with this approach...)
The problem with this workaround is, that i can't delete the generated excel file from my web page without the Session_End method in which i know when the user is finished with downloading. At least i don't know how to accomplish this.
Sorry for my bad english, i hope my problem is comprehensible :)
Thank's for replies.- Edited by Marioba Monday, December 14, 2009 5:58 PM weird editor
Monday, December 14, 2009 5:56 PM
Answers
-
I think you're right that you'd need an IIS application to use session state. However, I don't think you need to use session state. It looks like your only use of session state is the Session_End event. Session_End is based on a timeout, so you could probably write something similar as a cleanup process without session state.
Otherwise, an unsupported option could be to enable session state in the root web.config
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk- Marked as answer by Jim Glass Jr Monday, January 11, 2010 8:54 PM
Monday, January 11, 2010 2:42 PMModerator -
Thank's for your reply!
I have accomplished this task by creating a Windows Service which deletes the files created one day before execution time.
Not the best solution, but it works!- Marked as answer by Marioba Wednesday, January 27, 2010 1:02 PM
Wednesday, January 27, 2010 12:59 PM
All replies
-
I think you're right that you'd need an IIS application to use session state. However, I don't think you need to use session state. It looks like your only use of session state is the Session_End event. Session_End is based on a timeout, so you could probably write something similar as a cleanup process without session state.
Otherwise, an unsupported option could be to enable session state in the root web.config
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk- Marked as answer by Jim Glass Jr Monday, January 11, 2010 8:54 PM
Monday, January 11, 2010 2:42 PMModerator -
Hi there
Take a look at this walkthrough, it explains how to create and deploy custom aspx extensions to dynamics crm.
http://www.xrmlinq.com/kb/how-to-publish-link-customaspx-dynamics-crm/
XrmLinq - LINQ to Dynamics CRM http://www.xrmlinq.com - The smart way to query crmMonday, January 11, 2010 7:26 PM -
Thank's for your reply!
I have accomplished this task by creating a Windows Service which deletes the files created one day before execution time.
Not the best solution, but it works!- Marked as answer by Marioba Wednesday, January 27, 2010 1:02 PM
Wednesday, January 27, 2010 12:59 PM -
Hi,
the problem is that this example doesn't use IFD, so the website can be deployed as virtual application in IIS.Wednesday, January 27, 2010 1:02 PM -
I too have run into this issue in enabling an existing ISV solution to be IFD compatible. We use session state throughout the ISV application and it is needed. Is there any other option than enabling session state at the CRM web.config level?
If we do need to change the CRM web.config to enable session state is there any functionality in CRM that will be impacted?
Friday, April 9, 2010 1:14 PM -
In my case this problem was solved when enabling cross site scripting on the IFrame in CRM that was pointing to my ISV app. Additionally I changed the IFrame URL to be relative to the CRM root e.g. "/ISV/MyApp/default.aspx"
Once this was in place I was able to run my ISV app as a genuine IIS app and therefore enable session state in my application web.config independently of CRM.
- Proposed as answer by Paul Dowman Thursday, April 15, 2010 10:16 AM
Thursday, April 15, 2010 10:16 AM