Today my good friend Jafet asked me: "What do you think about sharing ASP classic and ASP.NET state?". And I told him that there were some projects for helping in this task.
I will mention some of them here.
The first one is NSession. This project provides an implementation that allows you to use the ASP.NET state server in ASP classic. You do not have to change your ASP classic code.
"You need to instantiate one of the COM objects in your ASP classic page before it accesses session state, either:
set oSession = Server.CreateObject("NSession.Session")
set oSession = Server.CreateObject("NSession.ReadOnlySession")
If you instantiate NSession.Session, the session state in the session store will be transferred to the ASP Classic session dictionary, and an exclusive lock will be placed in the session store. You do not need to change your existing code that accesses the ASP Classic session object. When NSession.Session goes out of scope, it will save the ASP Classic session dictionary back to the session store and release the exclusive lock.
If you have done with the session state, you can release the lock early with
set oSession = Nothing
If you instantiate NSession.ReadOnlySession, the session state in the session store will be transferred to the ASP Classic session dictionary but no locks will be placed."
The second option is SessionService. This project provides a mechanism for sharing the state between ASP classic and ASP.NET by serializing state data to an SQL Server. The project page provides detailed information on how to setup IIS, how it is used in both platforms.
And the third option is a very interesting one called ASPClassicCompiler. This is a great great project. It provides a mechanism for compiling the ASP classic to .NET. This project is now opensource and we need to thank Li Chen for it.
Great ideas can be implemented thanks to this source. For example Brian Ellis suggested using the VBScript engine to replace the MSScript.OCX. Another great one is an implementation of an View Engine that can be used with MVC and which support ASP Classic.
I really like the ASPClassic project and will be posting some interesting examples soon (as soon as I finish watching some Dr. Who episodes and the last Fringe season :) )
My friend roberto found this error and it seems to be a know .net framework error
If you run the application from a network share you will get an exception like:
System.Configuration.ConfigurationErrorsException: An error occurred creating the configu
ration section handler for overrideConfigurations: Request failed. (R:\Development\Junk\n
ewConsole\TestConsoleApp.exe.Config line 5) ---> System.Security.SecurityException: Reque
So the know workarounds listed in that page are:
http://support.microsoft.com/kb/182569Adding a ZoneMap for he the server/domain name with the network share and give it the Value 0 (Zone 0 = My Computer) did it!There is no GUI dialog to to this (because per default, you cannot change the "My Computer" zone in the internet settings.=>a) Hack the registry to get GUI access to the "My Computer" zone in the Windows internet settings and add the domain with the network share to the "My Computer" zone.b) Directly hack the registry by adding the network share machine name as a key to the Domains key of the ZoneMap (HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\) and give it the DWORD value "file=0".
And the other workaround (which I prefer is):
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var junk = config.GetSection("overrides/applicationSettings");
Maybe you faced the situation where you had code that was to be used on your server side services and also on your silverlight clients.
Having this situation required some tricks because Silverlight Class libraries could not be used on .NET projects and viceversa.
Common workarounds were to share files and use precompilation directive iack!!
Well VS 2011 has a concept called Portable Class Libraries which allow you to create class libraries that can be use in Windows Phone, Silverlight, .NET framework, etc.
And if you have VS 2010 you don't have to suffer. Just use the Portable Library Tools from from the VS Extensions and start sharing code (see this image form the VS Extensions site)
For more details about Portable Libraries check the MSDN documentation page: http://msdn.microsoft.com/en-us/library/gg597391.aspx