Wintellect Blogs

Where Oh Where Did My Response.SignOut Go in ASP.NET v.Next beta 6?

Rik Robinson

28 Jul , 2015  

If you’ve just fought through an update from ASP.NET v.Next beta whatever to beta 6 and now you’re staring down the last few red squiggled lines only to come across this little gem about SignOut no longer existing, I can help you get back to signing out in just a few steps.

 

image

 

AuthenticationManager

In this beta, it appears that the sign out functionality has been moved into AuthenticationManager.  Luckily, you have one of these already attached to your Context in the form of Context.Authentication.  So, the first thing you’ll need to do is replace your calls to Context.Response.SignOut() to instead call Context.Authentication.SignOutAsync().  You’ll want to also make the appropriate updates for async and such.  My original example above then becomes this instead:

 

Sign Out – but not really
  1. [HttpGet]
  2. public async Task<IActionResult> LogOff()
  3. {
  4.     if (Context.User.Identity.IsAuthenticated)
  5.     {
  6.         var authority = String.Format(_config.Get(“AzureAd:AadInstance”), _config.Get(“AzureAd:Tenant”));
  7.         var authContext = new AuthenticationContext(authority, new TokenCache());
  8.         authContext.TokenCache.Clear();
  9.         await Context.Authentication.SignOutAsync(OpenIdConnectAuthenticationDefaults.AuthenticationScheme);
  10.         await Context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationType);
  11.     }
  12.     return RedirectToAction(“Index”, “Home”);
  13. }

 

This gets you past the compiler and, if you run the above, you’ll find that it doesn’t give you any errors at runtime. … Read more

,

Wintellect Blogs

Azure Bits #4 – Adding the Azure Web Job

Rik Robinson

24 Jul , 2015  

This post’s main objective was originally about completing the initial skeleton of uploading an image from a web page and generating a thumbnail from an Azure Web Job using Azure Blob Storage and Azure Queues, but it turned into a pretty large refactoring in anticipation of having something a bit more realistic to eventually post to GitHub.  So, I’ll devote the first part of the post to a brief review of the most significant changes and then introduce the Azure Web Job into the mix and finally, I’ll retrieve the message from the Azure Queue and show its name in the console.  I’ll then devote Azure Bit #5 to processing the original image and generating a thumbnail to complete the initial skeleton of our Image Manipulator application.

Changing the Serialization Strategy

I’m not sure why I originally chose to go with serializing my UploadedImage to a ByteArray before inserting it into the Azure Queue, but I’ve now simplified things a bit and switched over to serializing my UploadedImage as JSON.  This allows me to drop the ByteArray extension methods that I previously added to the project and it buys me some nice auto-hydration of my UploadedImage later when my processing function is called in the Azure Web Job. … Read more

, ,

Wintellect Blogs

Azure Bits #3 – Adding a Message to an Azure Queue

Rik Robinson

16 Jun , 2015  

In Azure Bits #2 – Saving the Image to Azure Blob Storage, we were able to save our image to Azure Blob Storage and verify that this all went according to plan after re-publishing our site to Azure.

In this Azure Bit, we will take a look at the Azure Queue service and we will place a message in the queue to signal that our newly-uploaded image is ready to be processed.

The first thing we will need to do is to create our IQueueService/QueueService to abstract the interaction with the Azure Queue service.  We’ll just need one method for now.

 

IQueueService.cs
  1. public interface IQueueService<T> where T: new()
  2. {
  3.     Task AddMessageToQueueAsync(string messageId, T messageObject);
  4. }

We’ll need to know the queue name for our Azure Queue and we’ll need the Blob Storage Connection string, so I’ll go ahead and add the ImagesQueue name to our appSettings in web.config.

web.config – appSettings
  1. <appSettings>
  2.   <add key=ImageRootPath value=https://imagemanipulator3.blob.core.windows.net/images />
  3.   <add key=ImagesContainer value=images />
  4.   <add key=ImagesQueue value=images />
  5. </appSettings>

 

Finally, here’s the initial skeleton of QueueService. … Read more

, , ,

Wintellect Blogs

Azure Bits #2 – Saving the Image to Azure Blob Storage

Rik Robinson

22 May , 2015  

Creating the Azure Storage Account

In Azure Bits #1 – Up and Running, we got a skeleton in place for our web application that will allow the user to upload an image and we published our Azure Image Manipulator Web App to Azure.  Our next task is taking this uploaded image and saving it into Azure Blob Storage.

The first thing we need to do is to create an Azure Storage account in the Azure Portal.  Once logged into the Portal, you’ll want to click on the big green plus sign for New in the top left.

image

Next, you’ll want to select Data + Storage and then Storage to get to the configuration blade for your new storage account.

image

Here, you’ll want to enter a unique name for your Azure Storage account. Note that this name must be globally unique and must be a valid URL. You’ll also want to make sure that the physical location you select is closest to the consumers of your data as costs can increase based on the proximity of the consumer to the storage region. You can leave the rest of the information with the defaults and then click the Create button.  Azure will grind away for a bit to create your storage account as you watch an animation on your home screen.… Read more

, , , , ,

How To,Wintellect Blogs

Azure Bits #1 – Up and Running

Rik Robinson

12 May , 2015  

Badge-Azure

 

As Steve Porter mentioned in his blog post, How Wintellect Uses Microsoft Azure, we are making pretty heavy use of many offerings in the Azure toolset for our internal and client-facing web properties here at Wintellect and have been doing so from the early days of Azure. As we continue to experiment with new and/or improved Azure offerings, I thought it might be helpful to share some of the more interesting things we’ve worked through as we explore that ever-increasing world that is Azure.

As the first sample application for these Azure Bits posts, I will create a small image manipulator example in Azure. This example will allow me to demonstrate several pieces of the Azure stack working together, including an Azure hosted web app, Azure Blob Storage, an Azure Queue, and an Azure hosted WebJob.

Azure Image Manipulator

For this first version of the Azure Image Manipulator, the user will only be able to browse and select an image from their computer and submit the image for processing. When the user submits the image, the original image will be inserted into Azure Blob Storage and a message will be placed in an Azure Queue indicating that a new image has been uploaded and needs to have a thumbnail created.… Read more

, ,

Wintellect Blogs

Windows 8 Start Menu Toggle

Rik Robinson

20 Sep , 2011  

Since getting my hands on Windows 8 this past week, I (like many others) have really grappled with the constant accidental returning to the metro tiles every time I try to search for something in the new neutered Start Menu that appears in the Developer’s Preview of Windows 8.  To say I hate that would be an understatement. 

Today, a colleague forwarded m

e a link to a blog entry that showed the magic registry key to get my beloved Start Menu mostly back the way it was.  Apparently, there is a small GUI app on CodePlex that will take care of this as well. 

I decided I didn’t want to see anything, I just want to toggle.  So, I threw together a quick Console App to take care of this.  I can place this app on my desktop in Windows 8 classic mode and just toggle back and forth without having to see anything but a quick flash of the console. 

Here’s the code:

 
  1. using Microsoft.Win32;
  2.  
  3. namespace ToggleStartMenu
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var rootKey = Registry.CurrentUser;
  10.             var subKey = rootKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer",
  11.                 RegistryKeyPermissionCheck.
Read more

Wintellect Blogs

How to Scale a jQuery Mobile Site for iOS

Rik Robinson

25 Jul , 2011  

I was recently working on a jQuery Mobile application and everything looked great on my 21” touch monitor on several browsers, but when I deployed to the server and then hit the page on my iPhone, I ran into a few issues that I needed to work through in order to make the site what I’d call usable.

The first issue was that the site wasn’t scaling properly when it first loaded and everything was so small that I could barely click on it with my finger.  Certainly, this is not what I’d call optimal for a mobile site.

image

I originally played around with increasing font-size for the body and a few other quick CSS tricks, but nothing really did the trick.  I finally came across a meta tag which seemed to fix this issue. 

  1. <meta content="width=device-width, initial-scale=1" name="viewport">

This is what it looked like after adding this meta tag.

image

However, this created a new issue.  This second issue was that when I rotated from Portrait to Landscape mode, the web page did not scale properly and my toolbar buttons were now cutoff on the right-hand side like this:

image

I found numerous references to this known issue with iOS scaling and even found a few javascript fixes avail
able around the web.  However, after a bit of experimen
ting, I found that I could fix the issue with just a few tweaks to the meta tag above and using no javascript.  The final meta tag looks like this:

<meta content="width=device-width, minimum-scale=1, maximum-scale=1" name="viewport">

 

This is what the site looks like now when it’s rotated.… Read more

Wintellect Blogs

How to Include and Deploy Data using a Visual Studio Database Project

Rik Robinson

24 Jul , 2011  

I’m a big fan of Visual Studio’s Database Project and I’ve used them successfully in several client projects.  If you are not familiar with using the Database Project, I encourage you to give it a look.  It gives me a nice warm feeling to see that the database schema and even necessary seed data is maintained in source control in the solution right along with the other projects.  For developers that need to get up and running locally, the joy of simply right-clicking and choosing “Deploy” is hard to beat.  

Most any reasonably-sized application will have lookup lists and other data that need to be there for the application to function properly. To my knowledge, there’s not really an automated way in Visual Studio to tell the Database Project that you want to bring the data into the project and have it be part of your deployment. However, there is a way to tap into the scripts that Visual Studio creates when it creates a new Database Project.

This post specifically addresses including and deploying data and is not intended as a general overview of Database projects.  There is plenty of decent material available on doing that.  To follow along with this post, you can simply add a new project in Visual Studio and choose the Database | SQL Server project type and select the SQL Server 2008 Database Project.… Read more

Wintellect Blogs

Portable and Efficient Generic Parser for CSV

Rik Robinson

10 Jul , 2011  

I recently had some pretty ugly CSV files to parse and decided to have a quick look around to see if there were any libraries around that would handle the specifics of these particular CSV files without me having to write yet another CSV parsing class.  I found a couple that seemed to fit the bill on Code Project and I downloaded them both.  The two specific ones that I looked at were Sebastien Lorien’s Fast CSV Reader and Andrew Rissing’s Generic Parser.  The first one I tried was the Fast CSV Reader since it had some nice looking performance metrics on the Code Project page.  Unfortunately, it blew up on the first file and I decided to give the other parser a try rather than trying to debug why Fast CSV Reader choked. 

I next tried the Generic Parser and it handled the file and even managed to return me just my specific data and skipped all the miscellaneous comments and headers in the CSV files using just the default settings.  On a couple of the CSV files, I made a few tweaks to the default settings of Generic Parser to get the exact data values I needed.  So far, it has performed like a champ.   

There are many CSV parsers out there that are part of larger libraries of utilities and such, but for a quick solution to CSV parsing, I would definitely recommend having a look at Andrew Rissing’s Generic Parser.  I’d love to hear other’s experiences a
nd recommendations f
or CSV parsing libraries.  … Read more

Wintellect Blogs

Atlanta Code Camp Demos

Rik Robinson

7 Jul , 2011  

Another fantastic Atlanta Code Camp!   Big kudos go out to the crew that threw this together this year in record time and did a fantastic job.  I heard nothing but positive comments from everyone that I talked with.  Big thank you to the sponsors, volunteers, organizers, speakers, and attendees!

I gave two presentations this year: Intro to MEF for Silverlight and Intro to Jounce MVVM Framework for Silverlight. Thanks to the folks that made it out to the talks and especially those of you that stuck with me for both of them.

Here are the links to the slides and code:

Intro to MEF for Silverlight

Intro to Jounce MVVM Framework for Silverlight

(Note that these are zip files with 7z files embedded so you will need to unzip and then “un-7z” them. The files were huge as straight zips and the server wouldn’t let them through as 7z files. 7-Zip is free and will work on both zip/7z files).… Read more