Archive

Archive for July, 2014

.NET Uri, database not found, and encoding

I ran into an interesting issue when trying to debug some code a while back.  I had written a dynamic that would allow a person to authenticate and then pick a database in which to perform their operations.  For the most part, this system worked well and allowed me to keep things simple.  The part that was trick was that I had written my reporting and dashboard engine to use a single Razor .cshtml file to handle all requests.  It in turn pulled the report definition or dashboard definition XML files from the database.  The problem came when one of the SQL Server databases that the system was deployed was not the default instance but a “named instance“.

In my code, I would simply construct an Uri object and pass in the string that represented the parameters that I needed for the given page.  However, since a named instance uses the ‘\‘ character, this caused some problems as my simple string representation was not encoding the character and thus when the server received the request it was not a valid server name.  I spent hours thinking that it was a problem with the configuration with SQL Server.  It wasn’t until I debugged the .cshtml file that I realized that the name of the server was not coming across correctly and that I was not encoding the name properly.  Here is what I finally came up with to correct the issue:

string address = string.Format("../PreviewReturnSetupBillDesigner.cshtml?
Key={0}&ServerName={1}&DatabaseName={2}",
  101,
  HttpUtility.UrlEncode("monticello\test"),
  HttpUtility.UrlEncode("sample"));

Uri uri = new Uri(address, UriKind.RelativeOrAbsolute);

Previously, I was just passing in the server and database names without encoding them. This worked for all default installations of SQL Server but once you had a named instance in place, all bets were off.

Hopefully this will help anyone from spinning their wheels if they are doing anything similar…

Chrome auto fills email and password

July 25, 2014 1 comment

I have recently ran into a weird situation when testing some of my screens with Chrome.  Consider the following screen shot:

 

Screen Shot 2014-07-25 at 6.42.36 PM

 

As you can see, Chrome is auto filling my email address and password.  As this is a screen that I am designing, I was very surprised to see this behavior.  It took me a while but I found various solutions to the problem.  The one that I elected to use was more by choice of the designer I have built to create these screens than any other reason.

Place the following code before “Login Email”, as in my example:


<input type="password" style="display:none;" />

As you can see from the code above, we are basically creating an Input tag with the Type of Password.  We also set the Style to Display:None.  This ensures that it isn’t visible and fixes our issue with Chrome.

I hope that this is a temporary fix and that Chrome will work properly in the future but until then, we have ourselves a work around.

Here is a screen shot of the form now working properly:

Screen Shot 2014-07-25 at 6.52.45 PM

Hope this helps….

Categories: English Tags: , , ,

Nokia 1520 Windows Phone updates fails

If you are trying to update your software on your Windows Phone and you get the following error:

 

We are currently unable to check for updates.  (80072f8f)

 

This may seem like a strange message but most of the time the reason for this is that the date and time on the phone doesn’t match the Microsoft Windows Update Service.

Simply go in and make sure that your date and time are correct.  Also be sure that the year is correct as well.

Once you get that corrected, you should be able to check for updates and successfully communicate with the Microsoft Windows Update Service.

NOTE:  This should be a common fix for all Windows Phones.  Not just the Nokia 1520.  It happens to be the one that I am using for developing.

Hope this helps…

Microsoft MVP – Windows Platform Development

July 3, 2014 1 comment

Just wanted to let you know that I received a Microsoft MVP award. I am very excited and honored to receive such a prestigious award and want to thank all my readers for their support. I also want to thank all of the local supporters who have come out to hear me speak here in the Charlotte area.

My award area is Windows Platform Development and that is perfect as I have enjoyed spending a lot of time working on Windows Store applications and client-side MVC solutions.

This is a great honor and I will try my best to continue to earn it moving forward.

Categories: English Tags: ,