CSS is not applied on login page in ASP.NET

Hi All,
If you are working with asp.net and you tried to apply css classes on your web application which is linked in your master page. You might face a problem that the css classes doesn’t show on your login page but it shows properly after you logged in to your application by clicking on sign out link.

The problem is a security permission problem, since by default the asp.net application has a rule that doesn’t allow all users to access folder within your project, to fix this problem, you want to allow all users to access your css file in your folder, So let’s say you have css files in your <strong>Styles </strong>folder in your web project; You need to allow in web.config access for all users to access these files, so this fixes this problem in login.aspx page.

Add the following in your web.config to fix this issue:

<location path=”Styles”>
<system.web>
<authorization>
<allow users=”*” />
</authorization>
</system.web>
</location>


After applying this, try to run your application and you will see the css classes are applied on your login page.

Hope this helps.

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Deploy Your Facebook Application in Azure

Hi All,
If you trying to get started developing Facebook Applications in C#, Then you need to download facebook SDK in C#, and you can get the latest build from below link:
http://msdn.microsoft.com/en-us/windows/ee388574
After you install Facebook SDK, You will have good samples to get started and configure your application to be integrated with Facebook. After you will be able to successfully configure the first application. Then, If you want to deploy this application on Windows Azure, The question will be: How Can i deploy a sample website into Azure ? All samples provided in FB SDK are ASP.NET websites. As you might know, To deploy any web role in Azure you need to have a Web Application and Not a website. So the question how can i do this ? Please follow these steps:
1) Create a new Web Application in your solution.
2) Copy the Web.Config that you have in FB website and paste it in your web application.
3) Copy the code in Global.asax in FB Web site and paste it in your web application Global.asax.
4) You need to copy the code in FB web site master page and have it in your web application master page with updates to couple of controls.
5) Copy the code in web site default.aspx and paste it in your web application default.aspx.
6) Make sure to add latest Facebook.dll and Facebook.web.dll in your ASP.NET web application.
7) You need Facebook.MVC.dll if your application is a MVC ASP.NET application.
8) Make sure to update your web application web.config with the Facebook configuration.
9) Try to build and run your web application. You will be directed to facebook canvas page as configured in your web application.
10) Add a cloud service in your solution.
11) Add this web application as a web role and try to set the cloud service as a startup project.
Note: Make sure to target 4.0 .NET Framework.
Build & Test it out !
Hope this helps.
Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Thoughts & practices in Developing Cloud based solutions in Azure

Hi All,
I’m working for a while in designing and developing cloud based solutions using windows azure platform. In addition, I love working in the cloud and the concept to focus on developing business requirements rather than the infrastructure preparation and servers setup. I like the concept of the configuration management since you can build your virtual network and the server configuration form an XML file and with few clicks your project is hosted and deployed.

In this post i will share some ideas and thoughts that you might face or have in your mind when you start developing cloud based solutions.

1) Project Types: Using VS 2010, you can build different types to be hosted in windows azure, You can build web sites, web application in addition to back end services. The websites & web applications are called WEB ROLES. and back end services are called WORKER ROLES.

2) Databases: You can deploy your existing database by creating scripts in SQL 08 R2 Management studio that can have schema+data,schema only,data only and connect to the cloud DB server and run those scripts. then you db is ready to be used. The management console in Azure gives you the connection string to connect to your db under SQL azure tab.

3) DB size: As we have till now, you have 2 editions for DB: Web or Business, Web edition allow you to create DB up to 5 GB. and Business Edition allows you to create DB up to 50 GB. since we pay as we use in the cloud, you might start your project with specific size and then you need to extend this. and this is a FAQ for most of developers that have created their dbs and need to extend the DB size in the cloud

To change your DB edition and size option, check out this link:

4) VM configuration: Every deployment in Azure is a VM in the data center. So, you can configure the VM size and all deployment configurations such as: RAM,Processor,Trust level,Virtual Network setup…etc on your project before deploy it in the cloud. You can do this by right click on the cloud service project and select properties option.

To know more about how to configure your cloud project in VS 2010, check out this link:
http://msdn.microsoft.com/en-us/library/ee405486.aspx

5) Make sure to change the custom dlls required property Copy Local = True in VS 2010. So you will have them in the deployment package.

6) Here is a general troubleshooting tips for hosted services:
http://msdn.microsoft.com/en-us/library/gg465402.aspx

Hope this helps.






Regards,Mostafa Arafa
twitter.com/mostafaelzoghbi

How to calculate SQL Azure Storage per client in your DB ?

Hi All,
If you have a cloud based solution hosted in Windows Azure and you are using SQL Azure Database as a backend database. You will need to think about how much storage each client who is going to use your solution will consume from DB storage you have in the cloud. This concept is essential since the concept behind Software As A Service aka (SaaS) is to pay as you go. So, the client pays only for the storage he takes in the cloud and this is a competitive advantage you should give when you sell cloud based solutions.

Since you have a backend database that has all your clients data, You need to give the storage that has been taken by each client in your database. To do this, I was thinking that if i can get the Database size in MB and the size of each table.
I’d be able to calculate the storage for each client.

For example: If i have a table in my DB called Client, and set of tables Table1,Table2…etc.To get the total DB size in MB in SQL Azure, please check this command:

-- Calculates the size of the database.   
SELECT SUM(reserved_page_count)*8.0/1024  FROM sys.dm_db_partition_stats;   
GO

To get the size for each table, here is how to get the size of each table in SQL Azure:
-- Calculates the size of individual database objects.   
SELECT sys.objects.name, SUM(reserved_page_count) * 8.0 / 1024  
FROM sys.dm_db_partition_stats, sys.objects   
WHERE sys.dm_db_partition_stats.object_id = sys.objects.object_id   GROUP BY sys.objects.name; GO
So if i get the number of records in Table1 for client 1, So the storage that has been used in table1 by client 1 is equal to =Total Table Size * ( Client Records / Total Records ) 

Same will be calculated for all other tables.

The total amount of storage for client 1 is the summation Storage by client 1 for each table.
So you can show this amount in your interface under your system admin module and will be able to charge each customer on monthly basis for example.

Another question : What about the synchronization feature for cloud data in DBs ? You can either back up the database on periodic basis or do data sync in SQL Azure. Read more about SQL Azure Sync. framework:
http://archive.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=5037

Hope this Helps, Please post here any questions if something came across your mind ?
Thanks.

References:
- Monitoring SQL Azure Dynamic Management Views:




Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi