Sunday 15 May 2011

asp.net mvc 3 - Make change to a .cshtml file on Windows Azure Cloud Service -


We have a custom CMS site in which the administrator can make changes to _Layout.cshtml (since they are making many changes ). The site was hosted in Azure Web sites, but now we are taking it to cloud services

Now, the admin panel is reading and showing the contents of _Layout.cshtml (in fact, ~ / All files in the view / shared folder can be edited), but when the app is attempting to write to a file, it throws this error: Path 'F: SitesOutViewshaw Shared_Layout. Access to 'CSSM' is prohibited.

We are working on new ways to edit layout files, but before reaching there, we need a quick fix! I am using this method to write in the file: System.IO.File.WriteAllText (path, file resource);

Locally, in windows blue emulator, it is working correctly, but when it is hosted blue.

Thank you!

First of all, I have to say some problems even if you have your _Layout.cshtml can update the file

  1. If there are multiple instances of your web roll, once the administrator has changed the page, this only updates the file in the same instance , But others will not be changed by default. You have to somehow sync them.

  2. If your frequency has been moved to another virtual machine, for some reasons such as hardware failure or virtual machine processing, the allocation made by your administrator will be lost.

    That is why I strongly recommend amendment in your implementation about how to save the change part in the BLOB, table or database, then when the page was provided, you Retrieve content from DB. I think it would be better than just modifying the page.

    HTH

No comments:

Post a Comment