04 Nisan 2012 Çarşamba 07:43
I have declared a static string "drivePath" in Gloabal.asax.cs. In Onstart event of webrole I am assigning a value to it. I am accessing this value on my web page but it shows as if the variable is just declared. The value I get for the My code is as follows
public static string drivePath = string.Empty;
public override bool OnStart()
Global.drivePath = WebRole.drivePath;
I am assigning value to WebRole.drivePath in "MountAzureDrive()" function.
On Web Page
On the web page in some function I am accessing the drivePath as "Global.drivePath"and I am getting value as string.Empty.
My question is Why is not preserving the value of drive path? What do I have to here if I want to preserve the value of drivepath and get it?
Please help me
Thanks in advance.
04 Nisan 2012 Çarşamba 10:53
The code running in the WebRole is not the same process as your web application (Global.asax.cs). What you could do is the following:
- WebRole: Mount the drive
- WebRole: Store the drive letter as an environment variable
- Global.asax.cs: Read the drive letter from the environment variable.
Follow this article for more information: http://www.codeproject.com/Articles/81413/Windows-Azure-Drives-Part-1-Configure-and-Mounting
Sandrino Di Mattia | Twitter: http://twitter.com/sandrinodm | Azure Blog: http://fabriccontroller.net/blog | Blog: http://sandrinodimattia.net/blog
- Yanıt Olarak Öneren Sandrino Di Mattia 05 Nisan 2012 Perşembe 08:36
05 Nisan 2012 Perşembe 09:01
OnStart (Role) is in another process than your web page (pages, Global.asax ..). At least when using Full IIS Mode
So I implemented/moved the code of mounting azure drive from onstart event of WebRole to Application_start event of Global.asax.cs file and it worked.
After this implementation for testing you need to restart your emulator.