May 082013
 

Randy Patterson and I were discussing battery usage on the Windows Phone 8 (he has an HTC 8X and I have a Nokia 822), and he was struggling with poor battery usage. I asked if he had taken the time to manage his application background tasks, to which he stated “What do you mean?”. I took a few minutes to show him how to do it and he comment was “you should blog about this, I had no clue you could do this”. So, here we are and I would like to thank Randy for the blog idea.

To get started go into your “Settings” on your Windows Phone 8, once there swipe from right to left to get to the “applications” screen, then tap background tasks. You will see a list of applications the have a background task, and my rule of thumb is, if it does not have regular or wide tile on my start screen or the live tile data I don’t really care about then I block it to save battery time. Now you may ask “how do I block an application?”, as you can see below it is fairly painless to do - one in background task simply tap the app then tap block.

wp_ss_20130508_0001 wp_ss_20130508_0002 wp_ss_20130508_0003

Let’s take a quick look at my battery usage to see how I have things performing.  As you can see below I have almost 3 days of usage from a single charge.
wp_ss_20130215_0001

 

Now as a side note, if your mail supports push technologies like Office 365 or Outlook you don’t need to worry about the next comment.  if you use pop, you should set your POP email to check every 30 minutes to an hour, this will help increase your battery time as well.

Well I hope these suggestions help you, if you would like to know more please let me know.

 Posted by at 10:03 am
May 082013
 

For those that don’t know I am working on a book for Apress on developing applications for Windows Store. You can help me write it with there alpha program, which allows you to see the book as I am writing it. You can check out the book here.

 Posted by at 8:11 am
Sep 122012
 

For the second time this year I have the great opportunity to be one of the judges for the INETA Component Code Challenge.  Here are the details:

Have you ever thought “I have a good idea for an application, however what can I get for it?” and/or “I would love to go to DevConnections, but I am not sure how to pay for it?”. Well, you are in luck. With the INETA Component Code Challenge for 2012, all you need to do is create an application using 2 approved controls from 2 approved vendors, create a video talking about your application, and submit it to our judging panel. Our judging panel, consisting of Bill Reiss, Nikita Polyakov, Matt Hidinger, and Greg Leonardo, will be looking for innovation and creativity in the use of approved controls. To read official rules click here.

So grab your computer and Visual Studio and GET YOUR CODE ON!

Disclaimer: INETA covers one conference ticket, hotel, and travel to the conference as is outlined in INETA’s travel policy. Please visit the site for additional rules.

Sep 122012
 

The ASP.NET Universal Provide cover Membership, Roles, Profile, and Session solutions in MVC4 which can leverage SQL Compact, SQL Express, SQL Azure, and SQL Server.  The biggest deviation from old ASP.NET 2.0 Membership is the need to run aspnet_regsql.exe to install the database side before you are able to use them.  ASP.NET Universal Providers now provide the magic to setup the persistence store with simply providing the database connection string.

 

If you would like to install the Universal Providers, because you did not select Internet based project in the MVC4 project selection screen.  You can run the Package Manager to install but doing the following:

Package Manager Console in menu

And entering “Install-Package System.Web.Providers” at the PM> prompt.

 Posted by at 7:15 pm
Mar 022012
 

I learned about some security features in MVC3, that I had forgotten about.  So, let’s discuss them and the differences between authenticate and authorization as well as look at some standard attacks.  MVC3 out of the box supports Windows and Forms based authentication, Windows authentication are generally used for intranet applications and Forms based is general used for internet based applications.  With forms authenticate SSL needs to used to help protect the username and password being entered by the user.

To secure a controller action you can use the [Authorize]  attribute to secure an action or the controller itself.  If you use just the [Authorize] attribute, all you are really saying is you don’t want anonymous users to access the controller or action.  You can further define this by adding Roles or Users to the [Authorize] attribute, which is the authorization part of security in MVC3.

Now let’s talk about site attacks.

Cross-Site Scripting, which are defined as cookie theft, malware downloads, account hijacking, and modify content to name a few.  This is controlled by the underlying framework, however you can use [AllowHtml] attribute to the model property you would like to allow Html to flow through with minimal risk.

The Anti Cross Script library can be used to help sanitize the Html.

Cross site request forgery can be combated with the @Html.AntiForgeryToken() on your form declaration and ValidateAntiForgeryToken attribute on the post destination action in the controller.

Example:
In the View form definition.

[sourcecode langauge="csharp"]
@using (Html.BeginForm("Contact", "Home")) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
[/sourcecode]

In the Controller Action

[sourcecode langauge="csharp"]
[OutputCache(NoStore=true, Duration=0)]
[ValidateAntiForgeryToken]
public ActionResult Contact(string message = null)
{
EmailModel email = new EmailModel();
ViewBag.Message = message;
return View(email);
}
[/sourcecode]

Hopefully this give some insight into security options with MVC3, I will follow this up with MVC4 here soon.

Mar 022012
 

Today I was humbled in talking about architecture as I stumbled through some explanations of principles and key terms.  For those that know me I am very passionate and professional on how I approach things, including discussions.  I found myself stumbling because I got myself stuck on answering an open question about how I would architect something anyway I wanted to (skies the limit).  I struggled because everyday architects resolve issues within the constraints of budgets, personnel, and technology stacks.  It was like asking me, if you could do anything in the world, you want what would do?  Flight or invisibility?  But at the end of the day, the laws of gravity and physics comes into play.

I asked myself, why is architecture important?

Like everything else to me it is a process and with that it has defining characteristics.  Some of the main issues that seem to get focused on is acronyms and perceptions.  What I mean by that is acronyms have different meanings to different industries – they also seem to overlap.  Like a house, software needs a strong foundation to build on and without it everything built on top of it is at risk – do we really need to concern ourselves with what we call it.  Sometimes I think quite a few great discussions get last with acronyms and there usage

With that what should the goals of Architecture be?

The main focus should be bridging the gap between business requirements and technical requirements by understanding the software’s use cases and working out ways to implement them.

Well then, what key principles should an Architect consider?

  • Instead of building to last, build to change.
  • To reduce risk and model to analyze.
  • Use visualization as a collaboration tool.
  • Work to identify key engineering decisions.

With emergent architecture try using a more iterative or agile approach to help minimize risk of change throughout the process.

So, to answer the main question without a strong foundation you simple end with a house of cards, that is difficult to deploy, modify, manage, and support.  While architect by nature is conceptual, without walking that mile or suffering through a bumpy foundation – how do you really know what foundation to build?

 

Feb 072012
 

This year I have the great opportunity to be one of the judges for the INETA Component Code Challenge.  Here are the details:

Have you ever thought “I have a good idea for an application, however what can I get for it?” and/or “I would love to go to DevConnections or Tech•Ed, but I am not sure how to pay for it?”. Well, you are in luck. With the INETA Component Code Challenge for 2012, all you need to do is create an application using 2 approved controls from 2 approved vendors, create a video talking about your application, and submit it to our judging panel. Our judging panel, consisting of Bill Reiss, Nikita Polyakov, Matt Hidinger, and Greg Leonardo, will be looking for innovation and creativity in the use of approved controls. To read official rules click here.

So grab your computer and Visual Studio and GET YOUR CODE ON!

Disclaimer: INETA covers one conference ticket, hotel, and travel to the conference as is outlined in INETA’s travel policy. Please visit the site for additional rules.

Jan 182011
 

Printing in Silverlight has been made pretty simple, how it comes with some caveats because it opnly supports rasterized image printing.  Not 100% a problem but in LOB applications will run into issue with printing thinks like PDF, because all formatting is lost in reflect to the final printed document.

Here is a quick code method on printing in Silverlight 4:

[sourcecode langauge="csharp"]
PrintDocument documentToPrint= new PrintDocument();
documentToPrint.DocumentName = "Sample Document";
documentToPrint.StartPrint += new EventHandler(documentToPrint_StartPrint);
documentToPrint.PrintPage += new EventHandler(documentToPrint_PrintPage);
documentToPrint.Print();
[/sourcecode]

Jan 062011
 

The Life Cycle of a page when requested for the first time:

Initializing: During this phase, the server creates an instance of the server control

Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.

PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.

Saving: During this phase, the state information of the control is saved. For example, if a value is set for the control during the Load event, it is embedded in the HTML tag that will be returned to the browser.

Rendering: During this phase, the server creates the corresponding HTML tag for the control.

Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

The processing sequence in which a page is processed during a postback event is:

Initializing: During this phase, the server creates an instance of the server control

Loading view state: During this phase, the view state of the control posted by the client is reloaded into the new instance of the control.

Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.

Loading the postback data: During this phase, the server searches any data corresponding to the control that is loaded in the data posted by the client.

PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.

Saving state: During this phase, the change in the state of control between the current request and the previous request of the page is saved. For each change, the corresponding event is raised. For example, if the text of a textbox is changed, the new text is saved and a text_change event is raised.

Rendering: During this phase, the server creates the corresponding HTML tag for the control.

Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

The events associated with the relevant page cycle phases are:

  • Page Initialization: Page_Init
  • View State Loading:LoadViewState
  • Postback data processing: LoadPostData
  • Page Loading: Page_Load
  • PostBack Change Notification: RaisePostDataChangedEvent
  • PostBack Event Handling: RaisePostBackEvent
  • Page Pre Rendering Phase: Page_PreRender
  • View State Saving: SaveViewState
  • Page Rendering: Page_Render
  • Page Unloading: Page_UnLoad