Click Here to Install Silverlight*
IndiaChange|All Microsoft Sites
MSDN
|Developer Centers|Library|Downloads|How To Buy|Subscribers|My MSDN
 
Understanding .NET Alerts
By Saravana Kumar
 
Article Posted: July 29, 2003
 

Introduction

Microsoft .NET Alerts gives businesses a powerful new communication tool that allows them to reach customers and employees in ways that are relevant and actionable. .NET Alerts is an opt-in service in which users sign up to receive alerts from a specific provider, so that they can quickly be notified of important events and act on that information.
 
For example, rather than simply sending a customer an email message that could sit in an inbox for days, a .NET Alerts provider can send a simple XML message to the .NET Alerts service. This service then intelligently routes that message to a user's desktop, cellular phone, mobile device, or email address - all based on the user's preferences. The user can then click on that alert and be directed back to the provider's site.
 
 
An alert is a short instant message that content or service providers (referred to as .NET Alerts providers) can send to people who opt to receive them. The alert is routed based on the user's preferences and can be delivered to computer desktops, mobile devices, and any e-mail address. .NET Alerts offers online safety features, convenience, and user controls. Its subscription mirroring process helps to protect users from unwanted messages by checking for content to which they have not subscribed. Microsoft .NET Passport is an authentication method that helps protect your privacy, as described in the .NET Passport Privacy Statement. It makes the registration process efficient. Rather than entering personal information many times, .NET Passport users can quickly sign up for alerts on a provider site. Finally, .NET Alerts helps to give users control over how and when they receive alerts. The service is exposed through the Alerts tab of Microsoft Windows Messenger and MSN Messenger. Users can receive alerts on either Messenger client, a mobile device, or e-mail.
 
 
How .NET Alerts Work
 
A user needs a .NET Passport account to sign up for .NET Alerts. Once they log in, users are directed to a subscription page that enables them to configure their Alerts to be delivered to selected devices and apply rules about how they're received. For instance, you can specify that you'll receive .NET Alerts through MSN or Windows Messenger if you're online, and through your cell phone if you're not.
 
When configuring device options, the user actually runs Web pages from the Microsoft .NET Alerts Web site, so the look is consistent. However, the Web page is branded with the provider's company logo, so it appears to the user as if he or she is still on the provider's Web site. After users select device options, they're directed back to the provider's Web servers, where they select the type of information the Alerts will provide (See the below figure). Users can change the way they receive Alerts, or discontinue them at any point. The Subscription Mirroring Protocol handles this entire process.
 
Other part in .NET Alerts is sending alerts, that has to done by implementing your own logic for generating and sending alerts when some events is happening in your application or you can use SQL Server 2000 Notification services. SQL Server 2000 Notification services enables you to send personalized messages. Notification Services and .NET Alerts are complementary technologies. You can use Notification Services to generate messages, then pass them to a routing service such as the Simple Mail Transfer Protocol (SMTP) or .NET Alerts. If all you want to do is enable users to sign up for e-mails, Notification Services is a great product for streamlining this process. .NET alerts has few API for sending alerts.
 
 
Implementing .NET Alerts
 
 
Above Implementation flow diagram lists all the step you need to take to implement .NET Alerts. Capacity planning is a critical part of the process, and Microsoft requires you to complete a capacity-planning worksheet before becoming a provider. This involves estimating the total number of users, the number of Alerts sent per week, and so on. You complete a separate worksheet for each distinct Alert you plan to send out.
 
As mentioned in Implementation diagram, first you need to download the .NET Alerts SDK. The Microsoft .NET Alerts Software Development Kit (SDK) provides several components that help you implement .NET Alerts. It can be downloaded from this place:
http://microsoft.com/downloads/details.aspx?FamilyId=ABCA770F-BC2A-4F11-8036-3040EDC6DB78&displaylang=en
 
 
To Register Your Application
 
Next thing which you need to register your application with netservicesmanager . Here are steps of registering our application:
 
1. Sign in to the .NET Services Manager at https://www.netservicesmanager.com.
2. You will be prompted for contact information the first time you sign in to the site.
3. From the Home page, select Create an application.
4. On the Create Application page, in the Application Name field, type an application name to identify your implementation.
5. You can choose to either create a new application or base one on a previously created application. If you create an application based on an existing application, information from the existing application is used to populate the information fields.
6. On the Select Services page, from the Services box, select .NET Alerts, and click Continue.
7. On the Capacity Planning page, add one or more capacity planning scenarios, and then click Continue.
8. On the General .NET Alerts Information page, complete the required fields, and then click Continue.
9. On the Localized Site Information page, enter site information for each language you plan to support, and then click Submit.
 
After you complete these steps, your application is in a pending state and must be reviewed. You can expect a response to your capacity planning information within three business days.
 
If there are no problems, you will be approved for access to the PREP environment and can download your PREP key (InstallSDKKey.exe) from the .NET Services Manager. After downloading the PREP key, you should install it in your machine.
 
The InstallSDKKey.exe is a command-line utility that can be used to manage a Microsoft .NET Alerts provider's credentials on systems running Microsoft Windows 2000, Microsoft Windows XP, or Microsoft Windows .NET Server. The credentials are embedded in the InstallSDKKey.exe file. Upon registration, .NET Alerts providers receive this file customized with their credentials. The utility encrypts and writes a .NET Alerts provider's credentials to the Windows registry of computers that are using the .NET Alerts client library. The library retrieves credentials from the registry as they are required, eliminating the need for them to be specified elsewhere.
 
You must return to the .NET Services Manager to request a compliance review of your site and roll your site into Production.
 
 
Subscription Mirroring Protocol
 
The Microsoft .NET Alerts Subscription Mirroring Protocol defines the way in which a .NET Alerts provider interacts with the .NET Alerts service to create or modify subscriptions on behalf of a user. When a user subscribes to an alert from your Web site, the user is authenticated by the Microsoft .NET Passport system and silently redirected to the .NET Alerts subscription mirroring service. The subscription is registered in the .NET Alerts subscribers database and the user is silently directed back to your site. This redirection to your site includes status information indicating whether the operation was successful. If the call is successful, you record subscription data in your own subscribers database.
 
The following outlines a typical process flow for creating a subscription:
 
1. A user on your site clicks an Alert Me icon to subscribe to your alerts.
 
2. Using HTTP, you redirect the user to the Microsoft .NET Alerts subscription mirroring page. You include several parameters in the redirection URL, including an authentication token..
3. The Microsoft .NET Alerts Web site displays a page that enables the user to specify delivery settings for the new subscription. Although this page is on the Microsoft .NET Alerts Web site, it includes branding for your site as specified by your cobranding template.
 
4. After the user chooses delivery settings for the subscription, a confirmation page is displayed indicating that the subscription was successfully created, and that the delivery settings have been recorded. This page, like the delivery settings page, is cobranded.
5. The user is redirected back to your site, to a return URL that you specify in the initial subscription mirroring call. The return call includes status information indicating whether the call was successful.
6. If the subscription mirroring call was successful, make a record in your subscribers database for the new subscription
 
 
Send Alerts To Subscribers
 
The Microsoft .NET Alerts client library provides a convenient means for content providers to send alerts to subscribers. By using the objects provided in this library, you can create alerts (as abstracted objects) and submit them to the .NET Alerts routing engine for distribution.
 
S.No Object Name Description
1. NotificationTransport Provides a high-performance HTTP transport service for alerts.
2. MsnNotification Provides an abstraction of an alert.
3. NotificationsUtility Provides general support functions for the .NET Alerts client library.
 
Here is the code snippet for sending alerts from ASP.NET Web Page in VB.NET
 
Dim transport As NotificationTransportClass
       transport = New NotificationTransportClass()
       transport.DestinationUrl = "http://nrouter.microsoft-ppe.com/nrouter/nrouter.dll"

       Dim username As String = Nothing
       Dim password As String = Nothing
       Dim WaitForCompletion As Integer = 1
       Dim Token As Integer
       Token = System.Convert.ToInt32(1)
       ' Get all the events that have not been sent
       'Dim eventSet As SqlDataReader = alertSubscriptions.GetQueuedNotifications()

       Dim alert As New MsnNotificationClass()
       alert.MessageID = "0"
       Dim Context As System.Web.HttpContext = System.Web.HttpContext.Current
       alert.SiteURL = "http://" + Context.Request.ServerVariables("SERVER_NAME") +                         Context.Request.ApplicationPath
       ' The relative path to the action URL page, including two custom parameters,        param1 and param2.
       ' Note that the ampersand is XML-encoded.
       alert.ActionURL = "WebForm1.aspx"
       ' Specifies the user PUID as an argument to the subscription URL.
       alert.SubscribeURL = "WebForm1.aspx"
       alert.BodyIcon = "car.png"
       alert.BodyLanguage = "1033"
       alert.Priority = "1"
       'PUID is passport hexadecimal id which is got through querystring
       Dim PUID As String = Request.QueryString("PUID")
       PUID = "0x" + PUID.Substring(0, 8) + ":0x" + PUID.Substring(8, 8)

       ' Spin through the queued up notifications and attempt to send them
       alert.ID = 1
       alert.ToPID = PUID
       alert.SiteID = 41086
       alert.Body = "<TEXT>" + "You got a alert" + "</TEXT>"
       'alert.ActionURL = eventSet("ActionURL").ToString()
       Try
          transport.SendNotification(WaitForCompletion, username, password, alert,           Token)
       Catch ex As COMException ' Non-COM exceptions will propagate to Main().
          ' Wait a second to allow transient network problems to resolve.
          Thread.Sleep(1000)
             Try
                 transport.SendNotification(WaitForCompletion, username, password,                  alert,Token)
              Catch ex2 As COMException ' Non-COM exceptions will propagate to Main().
                    Thread.Sleep(1000)
                 Try
                     transport.SendNotification(WaitForCompletion, username, password,                      alert,Token)
                  Catch hr As COMException ' Non-COM exceptions will propagate                         to Main().

                        ' Custom error codes by the .NET Alerts SDK match 0x81fdxxxx.
                        Dim msg As String
                        Dim ErrorMessage As String
                        If Not ((hr.ErrorCode And &HFFFF0000) = &H81FD0000) Then
                             'msg = [String].Format("A COM error occurred while calling                              SendNotification:0x{0} {1}", hr.ErrorCode.ToString("x"),                              hr.Message)
                          Else
                             ErrorMessage = "An unexpected error occurred." End Select                         'end switch
                        End If
                        msg = String.Format("A COM error occurred while calling                               SendNotification: 0x{0}{1}", hr.ErrorCode.ToString("x"),                               ErrorMessage)
                 End Try
             End Try
       End Try
 
 
Configure Messenger To Use The PREP Environment
 
The Messenger Login server is stored in a registry key. To configure the client computer to use the PREP Messenger environment when a user signs in to Windows Messenger or MSN Messenger, update the value of the following string:
 
HKEY_CURRENT_USER\Software\Microsoft\MessengerService\Server
 
Specify the sign-in server name for the Messenger PREP environment. The name for the sign-in server is provided to you in an e-mail after you register a .NET Alerts application with the .NET Services Manager.
 
 
- Saravana Kumar
Microsoft Community Star
www.extremeexperts.com
 

©2009 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement
Microsoft