Showing posts with label asp.net. Show all posts
Showing posts with label asp.net. Show all posts

Visual Studio Online is definitely more than text editor online!

5 powerful features that make Visual Studio online an indispensable tool

If you are a .Net developer then you know Visual Studio. Few months ago, Microsoft released a new version of this tool call Visual Studio 2013 Community edition. This version offers all the features and is completely free. Many of us already have downloaded and installed this version. Another version is also available, but doesn't have the popularity of his brothers... yet. Let's talk about Visual Studio Online.
 

Get Started

Did you know that Visual Studio Online is available for free? Go to http://www.visualstudio.com/ and create an free account that will included:


  • 5 FREE Basic user licenses
  • Unlimited team projects and private code repos
  • FREE work item tracking for all users
  • FREE 60 minutes/month of build
  • and much more.... 

  • 1- It's a Source Control

    It may be called Visual Studio Online, but it has all the features from Team Foundation Server (TFS).
    Let's create a new project. From your home page, under the tab Overview (selected by default) click on New. This will pop the form to create a new team project. One interesting thing to note is that both TFS and Git are supported as Version control system.
    For the post I will create my project MyBookManager using Git.

    Create_project_with_VSO

    2- It's an Agile board


    Now that we have a project, it's time to describe it. Visual Studio Online has an entire section just for collaborative work. From the home screen of your VSO click on _Users_ tab. Create your users, roles and manage their permissions.
    It's now time to time to describe all the features of the project. Click on _Overview_ tab to get back to Home. Select your project, then click on _Work_ tab. From here you will be able to create all the features you need, and split them in tasks and sub tasks; perfect to fill-up a backlog item list and plan your next sprint.
    Once a sprint is started, it's also from here that you will be able to see and interact with the Board.

    board

    From this board, cards can be move by dragging them in the column that reflected the current status of the work. Open the on-premise Visual Studio. From the bar Team Explorer click on the little plug, and select: “Select Team Project…”. If your VSO Server is not present, just add it, then select the your project (ex: MyBookManager).
    For this post I will create an empty Asp.Net MVC project. In the Models folder I add a new class Book with very basic code.

    public class Book
    {
         public int BookID { get; set; }
         public string Title { get; set; }
         public bool Read { get; set; }
    }
    

    Then by right-clicking on the folder Controllers select the Add new Scafolded Item option, and use that to create our CRUD controller and views for the Book model we just created. Let’s check-in the code, and go back to VSO. You should see the code.

    To give more visibility to the work’s status, you can create very nice chart and pinned them on the Home page. To add a new chart, go in the Work tab select Queries.  You can use the existing query or simply create a new one. To add a chart to the Home page right-click on the query and select Pin to Home page.

    Home

    3- It's a build / Deployment server


    create_build_step_1If it's one think that seem always complex for a developer is the automation build and deployment server setup. With VSO no need for all that complexity and resources, only follow a short wizard and your build machine will be setup in Azure ready to deploy as soon as you want.  You can setup an automatic build and deployment from the Azure Portal and Visual Studio. In this post, I will use Visual Studio.

    From the Team Explorer bar in Visual Studio, click on Builds then New Build Definition, to get the wizard.

    Build_step1

    First step, just put a name who makes sense.

    build_step_2

    Step two, we need to choose what will trigger the build. I select continuous integration, so the build should start at every check-in.

    Build_process

    When I create my project I select Git as a source control, so for the next step I will need to expand the Build process template zone, by clicking Show details.  Then from the list select GitContinuousDeploymentTemplate.12.xaml.

    The build definition is done, save and let it there for now.

    4- It's a Code Editor


    If it's one feature that you could expect from a tool like VSO is to be able to edit code online.  The online version is obviously less powerful then the on-premise one, but still you will it very convenient and easy to use.

    Let's change the button in the book list to be more modern. First, select Code tab.  Now let's find the Index.html file under the View folder. Once the file is selected, click on Edit button. It's time to add some bootstrap classes to transform the look of our button. As you can see even we are in a web  browser we have IntelliSense. 

    Edit_online

    Build_overall_processHit Save and it will commit our change. Since we create a continuous build, this one should kick-in and build and deploy our changes. We can see the status of our build by going in the Build tab in Visual Studio Online. It’s also possible to see it in the Home page by pinning it.
    When the build will be done, our change will be visible in the website. Of course, this build is very simple, unit test and more complexes processes could also be implemented.


    update_Result_after_auto_deployed



    5- It's a Test server


    Another great feature is the possibility to create a test plan for the quality assurance (QA) tester. You could create it via VSO as a test plan by going in the last tab Test. And create a checklist,  so they can follow it to test the application feature by feature.  You could also record the action with Microsoft Test Manager and then do a load test on the website by running simultaneously multiple tests on different instances in Azure.

    Microsoft_Test_Manager



    Verdict

    Visual Studio Online is a great tool and win to  be now more. What are the features you enjoy the most in VSO?


    ~Frank B

    References

  • http://www.visualstudio.com/


  • Localization from url with Asp.Net MVC 4



    To offer a website in multiple languages using ASP.Net we simply need to add some resource.resx files to our project and voilà. Based on the language of the browser, IIS will match the localization resource. However, what if we want to give the choice to the user?

    The goal

    One pattern often used to achieve this, is to split the resource based on the URL.

    Ex:
    http://www.DomainName.com/EN/About for the English path
    http://www.DomainName.com/FR/About for the French path

    The needs

    We will need something to grab the desired language from the URL and set it as the current language.

    The Solution

    First, let's add a new route. Asp.Net uses routing to parse the URL and to extract information from it, while keeping the displayed URL more user friendly. The default route is {controller}/{action}/{id}. So without a new route, our language will be treated as a Controller name; but that’s no good.
    The route we want is {lang}/{controller}/{action}/{id}. We could just replace the default, but then what would happen to "normal" calls?

    The best thing to do is to add our localized route first and keep the default second. The way the routing works, it will use the first route that matches. Since we will use the two-letter code for chosen language, lets add the first part {lang}, which must be two characters long to be considered valid. You can see this in the code where I define a constraint using the following Regex: "^[a-zA-Z]{2}$".

    Class_RouteConfig
    Now that we have the language, we must change the user interface culture of the current thread. I decided to use an Attribute, making it easy to use. Under the Filter folder add a new class which inherits from ActionFilterAttribute. This method will check if "lang" is available from RouteData. If lang is present it will change the currentUICulture of the current thread. If "lang" is not part of the URL, then it will set it to the default.

    Class_LocalizationAttribute

    We could put the [Localization] attribute on all controller classes, but a best practice is to create a BaseController class and use it there.

    Class_BaseController

    Voilà, you can now change the language of the entire website by changing the URL.

    Bonus: Use it everywhere


    To use it in the view and the controller it's easy; just add the namespace and just type Resources.NameOfYourResourceString.
    To use it in the validation and the generated code from the model, we could use something like this:

    Class_PersonModel

    This way, in the view, the code will still stay clean and simple.

    @Html.LabelFor(model.UserName)

    I hope this post helps you in your development efforts. Any comments, suggestions and/or questions are welcome.
     

    ~Frank



    Reading Notes Special Books Edition

    For the last months I read few technical books.  I thought it could be interesting to add it.  This is not a complete review and it only reflect my personal opinion.


    EF CodeFirst coverProgramming Entity Framework: Code First 
    By Julia Lerman, Rowan Miller
    Publisher: O'Reilly Media
    Released: November 2011
    ISBN 10:1-4493-1294-2

    Note: By the time I write this post the version of Entity framework is 5.0.
    Even if this book was about the previous version of Entity framework, it’s a golden mine of information. I found very useful the example that helps me to understand how to define the relation and more importantly what was the deference between the attribute way and the fluent way. It was easy to read, because well explains not because it was doing only the “beginner” stuff. Since EF is really useful when starting a new project or even for a POC, I think this book should be in all developer’s bookshelf.

     
    PowerShell BestPractices coverWindows PowerShell 2.0 Best Practices
    By Ed Wilson
    Publisher: Microsoft
    Released: December 14, 2010
    ISBN-10: 0735626464

    If you are a .Net developer and you still don’t know PowerShell or don’t know why you should consider PowerShell than this book is not for you… You should read some Introduction books or post THEN read this book.
    This book is all about best practices. It will help you to structures your code or your library of scripts. That way, you will be able to understand and found and reuse all of it. Whether to do something in a build or to deploy something in Windows Azure or even just to quickly do a repetitive task this book will help to do it.  A book to keep nearby. 


    Claims-Based_CoverClaims-based Identity Second Edition device
    By Dominick Baier, Vittorio Bertocci, Keith Brown and Matias Woloski
    Publisher: Microsoft
    Releaed: April 21, 2010
    ISBN-10: 0735640599

    This is definitely THE book to get started with claims. It starts right at the beginning explaining what’s a claim, why we should use it.  Many different scenarios are presented. Each of them is presented with and without claims and most of the time how to migrate from one to the other.  The complete solution is available on codeplex.com and if a PDF is good enough for you; it's also available on codeplex for free. 


    Building N-Layered Applications with ASP.NET 4.5N-Layer_Build_cover
    By Imar Spaanjaars
    Publisher: Imar.Spaanjaars.Com
    Released: July 2013

    This document is, in fact, a series of post about the best practices related to Asp. Net 4.5. While writing this notes, only two or three posts were available online. To get the full document with the source code you must pay. Eventually, all parts of the rich document will be available for free, but it's only 20$ and its own is value.
    The solution explained in this document is simple enough so it’s easy to understand the architecture but detailed enough to cover most of the case.  The solution will include a lot of technologies like: Entity Framework, Asp. Net MVC, WCF Services and many patterns: Dependency Injection, Repository, Unit Test, Mocking, etc.
    It’s a really well done document, and I think it’s a must to any web developer or architect.

    Microsoft SharePoint 2013 App Development
    Microsoft® SharePoint® 2013 App Development
    By Scot Hillier, Ted Pattison
    Publisher: Microsoft Press
    Released: November 2012
    ISBN 10:0-7356-7498-1

    I read this book to know more about the new “Apps” thing.  While I was ready, I understand that my project was not a good match for SharePoint App, so I didn’t finish it… yet. However, I found the book explications really clear, and it gives me all the tooling and options I needed to get started.
    Since Apps are now very present in SharePoint, I decided to include it in my notes.



    ~Frank






    Reading Notes #40

    Cloud


      Programming


        Miscellaneous


        ~ Frank


        Reading Notes #24


        Cloud



        Programming

         

        Miscellaneous


        ~Franky

        The Magic Provider (also call Universal Providers)



        My first Azure project was the migration of an existing web site in the cloud.  “Piece of cake”, I think. I was not so far, but I got one little issue why the membership and the session state.
        Back then the best solution was to use the AspProviders, a project in Microsoft Azure Samples.  The projet need to add to the solution and special SQL script, done by the Azure Team, need to be run to modify the AzureSQL database.  Once some tweaks to the config files were done, it was working.  Not bad, but it could be easier.
        Today, thanks to the NuGet magic, we have the ASP.NET Universal Providers! With this package we only need to execute one command: Install-Package System.Web.Providers, and voilà! No more config files manipulations, no more SQL script to run, no more nothing.   Just install and run it.
        It really works! 
        Install-Package System.Web.Providers
        Of course it’s still in alpha (version 0.1) but it’s all ready working nice.  For a more complete introduction I suggest you to read the great post that Scott Handselman wrote on is blog: Introducing System.Web.Providers - ASP.NET Universal Providers for Session, Membership, Roles and User Profile on SQL Compact and SQL Azure.

        ~ Franky

        References:

        Lecture de la semaine #4


        Cette semaine il y a une “petite” tendence…

        ~Franky

        Le MvcScaffolding expliqué par Steve Sanderson


        Récemment est arrivée NuGet, avec sa panoplie de packages.  Un qui avait particulièrement attiré mon attention était le MvcScaffolding.  Ce package permet de générer du code passé sur un modèle.
        Dans cet article, Steve Sanderson, explique de façon très claire comment utiliser ce puissant outil. À lire absolument!


        MvcScaffolding: Standard Usage: Steve Sanderson’s blog: "MvcScaffolding: Standard Usage
        MVC, ScaffoldingJanuary 13th, 2011
        This post describes some of the basic functionality you get with the MvcScaffolding package as soon as you install it. First, though, let’s explain a few core concepts. Don’t worry, there aren’t too many strange new concepts…
        If this is the first time you’ve heard about MvcScaffolding, check out this other introductory post first.
        What is a scaffolder?"

        ~ Franky

        Important: ASP.NET Security Vulnerability - ScottGu's Blog

        Scott Gu vient de mettre sur son blogue un important message expliquant une vulnérabilité de Asp.Net, ainsi qu'une façon de contourner le problème en attendant une mise à jour.

        À lire absolument si vous développez avec Asp.Net.


        A few hours ago we released a Microsoft Security Advisory about a security vulnerability in ASP.NET. This vulnerability exists in all versions of ASP.NET.

        This vulnerability was publically disclosed late Friday at a security conference.� We recommend that all customers immediately apply a workaround (described below) to prevent attackers from using this vulnerability against your ASP.NET applications.

        What does the vulnerability enable?

        An attacker using this vulnerability can request and download files within an ASP.NET Application like the web.config file (which often contains sensitive data)." [read more]

        ~Franky

        Read all of ASP.NET MVC 2 in Action now while you wait for the printed book

        I just read this on the Jeffrey Palermo's blog, awesome reading.  I'm in a hurry to start...
        image
        Read all of ASP.NET MVC 2 in Action now while you wait for the printed book : Jeffrey Palermo (.com): "First, you should place your advance order for ASP.NET MVC 2 in Action at http://manning.com/palermo2. That way, you will receive the printed book even before you see it at your local bookstore.
        The entire book is finished, and we are just moving through production right now. But that doesn’t mean you have to wait to read it and learn about ASP.NET MVC 2. Since the beginning of the book project, you have been able to see the progression of the book on GitHub, our project site and version control system. That’s right, version control is for more than just code!
        Head over to http://github.com/jeffreypalermo/mvc2inaction and go to the “manuscript” folder to read the entire book in Word document form. All the content is there. In fact, the Word documents for the 1st edition is there as well. You can see just how much we have expanded the 2nd edition to not only cover version 2 but also to incorporate lessons learned using the framework over the last 2 years."
        References: http://jeffreypalermo.com/blog/read-all-of-asp-net-mvc-2-in-action-now-while-you-wait-for-the-printed-book/