ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications. Real-time web functionality is the ability to have server code push content to connected clients instantly as it becomes available, rather than having the server wait for a client to request new data – Microsoft

Normally server sends notifications to clients when communication is initiated by some client but there are situations when we want server to push data to clients even there is no request from any clients.
Here is step by step procedure to do so.

Step 1
Add hub class, right click (on the App_Code in case of website project or appropriate folder in case of web application project), select Add and then Add New Item. Select the SignalR Hub Class template, give it a name say BroadcasterHub and click Add.
Your class should look like below:

using System; using System.Collections.Generic; using System.Linq; using System.Web; using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; [HubName("mainBroadcasterHub")] public class BroadcasterHub : Hub { private readonly Broadcaster _broadcaster; public BroadcasterHub() : this(Broadcaster.Instance) { } public BroadcasterHub(Broadcaster broadcaster) { _broadcaster = broadcaster; } } read more

You can create the user in Microsoft SQL Server & Microsoft Azure SQL Database using the following code.

  • Connect to master database and execute the following script:

    CREATE LOGIN UserNameHere WITH password='Password here';
    CREATE USER UserNameHere FROM LOGIN UserNameHere;
    
  • Then connect to the desired database and execute the following script:

    CREATE USER UserNameHere FROM LOGIN UserNameHere ;
    EXEC sp_addrolemember 'db_datareader', 'UserNameHere';
    
  • read more

    Recently we were in a situation where we need to merge data from our offline version of application with online database.
    We planned to use uniqueidentifier as data type for ID columns instead of int (auto identity).

    But when we looked at reviews a lot of people were against this idea, they said if we use uniqueidentifier column as primary key (and clustered index) then there will be lot of fragmentation in our database, also the extra size of key.

    Some people suggested that use the int type (auto identity) as primary key and add another column of uniqueidentifier type for this purpose. We decided to go with this idea and added a uniqueidentifier column in each table. read more

    Hosting providers unload your application after certain amount of time if the application is idle. Microsoft Azure provide Always ON option (with some extra cost) to keep the application always running. You can enable these settings from Azure Portal as show below:

    However there is an issue if your application is running on HTTPS and you have rewrite rules to redirect HTTP traffic to HTTPS then Always ON settings in Azure will not work.

    You can fix it in many ways, here is one of them. Add the following rewrite rule in your web.config, it should be first rule (if you have other rules in web.config): read more

    DateTime.Now returns the time by taking into account server’s time zone on which application is hosted. As Azure web apps has time zone set to UTC even its location is somewhere else say in central US.

    When we try to access the server’s time using DateTime.Now, it returns UTC time.

    You can fix this issue by adding the following application settings using Azure Portal:
    Key: WEBSITE_TIME_ZONE
    Value: Time zone of the application where it is hosted in Azure say Central Standard Time

    You can get the name of time zones from here read more