Categories
ASP.NET Microsoft Software Development Web Development

Updating Angular 2 + ASP.NET Core Web Template for Visual Studio 2017 RTM

I am currently starting a new project for ASP.NET Core 1.1 when I suddenly realized that there’s a template that I can probably use for this.  Unfortunately though, the VS extension isn’t updated yet for Visual Studio 2017.

blog-01-vs2015

If you try to install this with only VS 2017 installed in your machine, you won’t be able to and you’ll be faced with this error –

blog-02-install-error

Fortunately, not all is lost yet. You can still install this template on your machine by doing the following:

Categories
ASP.NET Web Development

Extend your ASP.NET SignalR web app functionality with Project Westminster (with examples!)

projwest

Project Westminster is one of the Universal Windows Platform (UWP) Bridges from which we can extend functionalities of our existing web applications using UWP runtime frameworks (toast notifications and responding to certain actions, camera API, contact sharing at the very least). In a nutshell, your web application published to the Windows Store with defined remote URL list that has access to the UWP APIs, and there you have your hosted app! Once published as a hosted web application (HWA), there’s no need to re-publish the app to Windows Store. Changes to your web application is pretty much your usual development workflow as most content delivered from HWA are coming from your app.

Categories
ASP.NET C# DotNet Microsoft SignalR Technology Web Development

ASP.NET SignalR – Beyond the Chat Application

Last January 30, I talked about ASP.NET SignalR 2.0 and what are the other uses of the technology aside from the chat application that’s widely available in the internet.

The first time I talked about SignalR (Q2 2013) is about the overview of the technology, and how it is used based on the chat application. From that point, I haven’t seen any implementation yet on how can it be used in business applications – a world where I actually work in. Although a quick check now on the project’s SignalR GitHub page, there are some projects/applications published using this technology.

Fortunately, an unfortunate incident that was reported before by a friend was a good business case where this technology can be implemented. The scenario is something like this:

Employee was working on an application where the users are located on multiple locations and multiple timezones. Employee worked with the business partner to schedule the production release of the approved enhancements. Business sent out prior notifications to the departments through e-mail and employee worked on the technical team that will assist in the release. Departments are responsible for cascading this information to their respective units as they are more aware of the specific roles for their group.

The release was made but had to be pulled out minutes after due to business reasons. The time in between the post release and the time it had to be reverted, data corruption happened and these needs to be corrected. It took a long time and large effort to reach out to different users to remediate data fixes.

A root cause analysis was conducted and one of the suggestions is that in the future releases, introduce the app_offline.htm file in the root folder of the application to make sure that no one is actually working on the application on the time of the release.

While the app_offline.htm file effectively excludes everyone from the application (aka “soft offline”), this might be costly for some who are currently working on the application. Either they had to re-upload a large file, re-input lots of data once an abrupt “activation” of the app_offline.htm file is put into place. It would be nice if these people would be notified of the upcoming outage ONLY if there’s a way to identify their current site activity and send them notices as warning to save their changes.

Building up a prototype using SignalR might be useful for these reasons:

  • Current users of the application are considered as “clients” connected to the server. Application administrators don’t need access to the web server just to get the number of users online (through perfmon) OR use an application level variable (and using that nasty Application.Lock() method) that can probably cause performance penalties.
  • I can treat the whole application as a glorified “chat session” and send broadcast messages to all or specific users (more on the sample application). I can send notifications individually or to everyone, as I desire through divs triggered according to events.

In my talk, I used two pages to demonstrate SignalR. It all started with converting a SignalR 1.x application to version SignalR 2.0.x and build the demo from that.

Client Page (signalr-Notification.aspx)

The client page provides three different ways of participating in the application session (or “chat”) – using the current windows identity, a client-input name, or a value taken from the web.config.

Image

Once you have selected your “identity”, you would see a familiar chat window similar to the chat demo. What made this demo different is that you have three functionality that builds on top of the chat demo.

The first two buttons in this page provide notification to all connected users, while the last one just provide notification to the user calling the function. The first button sends notification based on a fixed value. This could either be a standard greeting to those joining the session or any hardcoded value (e.g. name of the application, etc) that you wish to broadcast.

The second button broadcasts value from the web.config file. As indicated in the scenario above, it would have been better if the current users using the application prior the updates be notified that the application would go offline in x number of minutes. Case for example, if the website is scheduled to go offline in a specific time, you can get the value of the offline schedule (date or datetime) from the web.config and broadcast it to the users. This button is quite flexible on what data to broadcast or notify since you have control on what data to display to the connected users.

The third button simply displays how many users are connected to the application at that point. That’s just it. You would know how many people are actually having an active session with the application. Previously on ASP.NET Membership, the basis of number of users online is based on the users’ login session. However, if I say I login and close the browser after authentication, I would still be recognized as “online”.

Admin Page (signalr-Admin.aspx)

Getting through the admin page needs you to be identified again in the system. I just basically reused the first page and added admin-related items.

In the admin page, I displayed all connected users and their corresponding connection IDs. From this point, the “admin” can send individual messages to the user or broadcast to all a message. This is similar to a Facebook notification wherein people associated or a specific person gets notified for an update or message.

Admin

The demo files can be downloaded through my Skydrive folder and is provided as is.

There are other enhancements/items that I am working on this project:

  • Ability to return back to the admin who among the users have acknowledged the notification. An event can be raised and capture the current username of the user who clicked the notification.
  • Do a comparative speed/latency test on connections coming from different browsers. Note that SignalR’s mode of transport depends on the type of browser that a user uses to work with the application.

Questions? Feel free to ask them in the comments. 🙂

Categories
ASP.NET C# DotNet Web Development

Extending the ASP.NET CreateUserWizard Control

The CreateUserWizard control (CUW) has been a significant addition to ASP.NET since it has been introduced in ASP.NET 2.0. It simplifies the method of adding users in our web applications without having to write additional lines of code and the information is stored, by default, in a Server Express database file in the App_Data folder of our web application.

In the Security section of the ASP.NET Forums, a lot of times questions have been asked on how to extend the CreateUserWizard control in ways such as adding additional fields in the CUW, and how to use e-mail instead as the user account’s username. Steps to accomplish these are explained below:

Categories
ASP.NET DotNet Web Development

Using MySQL with ASP.NET with Membership and Roles

One of my instructors in college asked me if it’s possible to use MySQL as a storage engine with ASP.NET and likewise use it with membership. I was a bit surprised since I haven’t touched MySQL for quite a long time and while it is possible, I never thought I would be encountering a situation like this.

I already have a WAMP system set-up in my machine, thanks to the XAMPP package for Windows but I only use Mercury in that package for testing sending out of e-mails in my web applications. Further, I have downloaded the latest MySQL connector for .NET applications and so I went.

Firing up Visual Studio 2008, created a .NET 2.0 website and followed this – it worked until step #15. I am not sure if it’s because the version but by default, the MySQL role provider didn’t appear in the website configuration tool. Since the content might change, I got a page print of the current version (as of this writing).

Here are some tips that I will provide: