Showing posts with label Visual Studio 2012. Show all posts
Showing posts with label Visual Studio 2012. Show all posts

Thursday, 15 August 2013

Finline Touch–Windows Phone App Store

I am happy to announce that my first windows phone 8 app Finline Touch is live on Windows Phone Store. Few of the screenshots from the application is given below.

wp_ss_20130811_0002[1]wp_ss_20130811_0003[1]wp_ss_20130811_0004[1]wp_ss_20130811_0005[1]wp_ss_20130811_0006[1]wp_ss_20130811_0007[1]

Your Pocket personal finance tool to track and plan your investments. It includes the following calculators:

  1. Loan Calculator, for mortgage, car or personal loans
  2. Special Loan calculator, supporting 0% EMI and down payment
  3. Fixed deposit calculator, supports simple interest and interest compounded annually, monthly, quarterly and semi annually.

First version of this application can be downloaded from Windows Phone Store from the this link : http://www.windowsphone.com/en-in/store/app/finline-touch/e004e119-7f4b-46f1-bda5-aa1b1b94e6ef

Share:

Friday, 7 June 2013

Making Your Windows Phone ready for Development Simplified

Now that you have got a new Windows Phone, if you are a .NET Developer then next thing you might want to see your programs running live on WIndows Phone and feel your application with touch and gestures.

But let me tell you that you are still $99 USD (annually) and few steps behind to fulfill your dream, provided you don’t have Promo Code or DreamSpark subscription, if you have the MSDN Subscription you can generate the Promo Code from the My Account menu and Activate your Window Phone Developer account.

image

Once you are ready with your subscriptions, follow the steps below.

Step 1 : Registration

Go To Start Screen, Locate Windows Phone Developer Registration

image

Make Sure to Unlock the Screen by entering the PIN or you you have not set the PIN then simply Swipe the screen to Unlock. If you Have not Unlocked your screen you might get the error as below(Please unlock the phone screen on your phone and click “Retry” (ErrorCode:0xC)).

image

Step 2: Now Once you Unlock, the wizard will identify your Phone and Select Register, which will ask you to register you phone with you Live ID or Microsoft ID.

During the entire process keep your phone in Unlocked State, it will take few seconds then comes the next error if you are not registered with Developer Centre, (Device not registered with Marketplace. Please return to the Windows Phone Dev Center for more information (ErrorCode:0x80043001))

image

You can find the list of registered devices by logging into your Windows Phone Developer Account by going to this link

https://dev.windowsphone.com/en-us/Account/Devices

Step 3 : Registration to Windows Phone Dev Centre

This means you need to register yourself using this link : https://dev.windowsphone.com/en-us/join to Windows Phone Developer Centre, this will charge you $99 for a year subscription, or if you have a promo code or if you are a DreamSpark student then this will be free for you.

Once you Register yourself, then you may wait for sometime (~24 hours) for your account to get verified and activated. Finally after you complete all the steps above open the Windows Phone Developer Registration and try again you will get the message “Congratulations! You have successfully unlocked your Windows Phone.” This means your are ready to go and run your code on your Windows Phone device.

image

3. First Hello World in your Device

Once you have successfully registered your Phone to Windows Phone Developer Centre, open your Visual Studio 2012, Create a New Project and Select Windows Phone from the templates.

image

You can select the language of your choice, for this post I am selecting Windows Phone HTML5 App and select Ok to create the project with default settings and files.

Open the index.html, under Html folder of your project and just personalize your page with something of your choice.

Please make sure to keep the phone connected and Unlocked before you deploy and run your first Windows Phone Application on your device.

Now to run the application you can find the Device button as given in the screenshot below, you can also test your phone by clicking on the Simulation dashboard, highlighted below.

image

Now lets run my First Windows Phone App, make sure your phone is unlocked otherwise your deployment will fail. You can find the screen something similar to the one I have given below.

wp_ss_20130623_0003

4. Subscription Benefits.

With this subscription you can

  • Get free development tools, including a phone emulator to test your app
  • Explore code samples and all the information in our developer library
  • Read tips about selling your app
  • Review our policy guidelines and certification requirements
  • See tips and guidelines for creating apps that reflect the beauty of our design concepts
  • Create apps with trial options
  • Enable in-app purchasing, so customers can buy things within your app
  • Test your app with a real phone
  • Submit free and paid apps to the Store
  • Distribute your app around the world and set country/region-specific price tiers
  • Watch your progress and manage your apps in a personalized dashboard
  • Ask questions, share advice, or talk with other Windows Phone developer

5. Other Useful Links

For more details and FAQ visit : http://msdn.microsoft.com/en-US/library/windowsphone/develop/ff769508%28v=vs.105%29.aspx

Enjoy coding you Windows Phone Apps !!!

Share:

Wednesday, 24 April 2013

Device Detection in ASP.NET MVC 4

In this example I am going to demonstrate the MVC 4 Device detection libraries. ASP.NET MVC 4 introduces Display Modes to which allows you to write device specific application. This is a newly introduced feature of ASP.NET MVC 4. This selects a view depending on the browser making the request, which means you can target specific devices and present the user device specific customized pages.

By default Display Mode Provider implements the mobile view;

clip_image002

You just need to provide the mobile specific pages to your application by just creating a pagename.mobile.cshtml and you are done.

clip_image004

I have done few customizations in my Web and Mobile pages just to display the requesting browser UserAgent and to identify if this is a page for web or mobile. Now let’s run the application and see output.

I have used Mozilla User Agent Switcher Add-on here to switch between the browsers. clip_image002[4]

Page displayed by default User Agent (Desktop)

clip_image004[4]

Page displayed when I select the iPhone as User Agent.

You can notice here that this all achieved without even writing a piece of code till now, with just the addition of .mobile.cshtml page I am able to achieve this.

But in real world things are not so straight forward, we have plenty of devices emerging every year and we have to provide device specific pages for each one of those devices with very little or negligible development effort and of course with minimal code changes.

With display mode provider we cannot just add a device specific pages instead we can also specify Browser specific page, OS Specific pages and even Vendor specific pages yes that is true. The only thing what we need to know is the identifiable user agent which provides us enough information about the Browser, Device, OS, etc information.

Now let me add some customization to my code for iPhone. In this case I am going to display a page which is specific to only iPhone. First of all let’s create a page for iPhone as Index.iphone.cshtml

clip_image006

You can and add some code which will tell us on runtime that this page is only meant for iPhone. Now add few lines of code in Global.ascx.cs file. Here in these codes I have added entry into the DisplayModeProvider for iPhone, this will tell the application that whenever you see the iPhone text in the browser UserAgent, just take the user to Index.iphone.cshtml page.

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iphone")



{



     ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("iphone", StringComparison.OrdinalIgnoreCase) >= 0)



});






Now let’s see the output at runtime,



clip_image002[8]



Here in the screen above you can see that I have got an additional entry for iphone in DisplayModeProvider collection, and the output screen I got from the code is as below:



clip_image004[9]



Similarly you can add as many entries as you wish, and for e.g if you want to have same page for multiple devices like for iPad and Tablet I want to display Index.tablet.cshtml page, then you can write the codes as:





DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("tablet")



{



    ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("tablet", StringComparison.OrdinalIgnoreCase) >= 0



    || context.GetOverriddenUserAgent().IndexOf("ipad", StringComparison.OrdinalIgnoreCase) >= 0)



});




So you can see DisplayModeProvider is fully customizable and extensible based on your requirement. But the catch is you need to have a complete list of Browser User Agents to handle virtually all the possible devices programmatically from your code. For I came across one very interesting link from Tech Brij Blog, including the code provided in this blog will complete this example and you can have a complete working example of the device detection using MVC 4





private static string GetDeviceType(string ua)



{



    string ret = "";



    // Check if user agent is a smart TV - http://goo.gl/FocDk



    if (Regex.IsMatch(ua, @"GoogleTV|SmartTV|Internet.TV|NetCast|NETTV|AppleTV|boxee|Kylo|Roku|DLNADOC|CE\-HTML", RegexOptions.IgnoreCase))



    {



        ret = "tv";



    }



    // Check if user agent is a TV Based Gaming Console



    else if (Regex.IsMatch(ua, "Xbox|PLAYSTATION.3|Wii", RegexOptions.IgnoreCase))



    {



        ret = "tv";



    }



    // Check if user agent is a Tablet



    else if ((Regex.IsMatch(ua, "iP(a|ro)d", RegexOptions.IgnoreCase) || (Regex.IsMatch(ua, "tablet", RegexOptions.IgnoreCase)) && (!Regex.IsMatch(ua, "RX-34", RegexOptions.IgnoreCase)) || (Regex.IsMatch(ua, "FOLIO", RegexOptions.IgnoreCase))))



    {



        ret = "tablet";



    }



    // Check if user agent is an Android Tablet



    else if ((Regex.IsMatch(ua, "Linux", RegexOptions.IgnoreCase)) && (Regex.IsMatch(ua, "Android", RegexOptions.IgnoreCase)) && (!Regex.IsMatch(ua, "Fennec|mobi|HTC.Magic|HTCX06HT|Nexus.One|SC-02B|fone.945", RegexOptions.IgnoreCase)))



    {



        ret = "tablet";



    }



    // Check if user agent is a Kindle or Kindle Fire



    else if ((Regex.IsMatch(ua, "Kindle", RegexOptions.IgnoreCase)) || (Regex.IsMatch(ua, "Mac.OS", RegexOptions.IgnoreCase)) && (Regex.IsMatch(ua, "Silk", RegexOptions.IgnoreCase)))



    {



        ret = "tablet";



    }



    // Check if user agent is a pre Android 3.0 Tablet



    else if ((Regex.IsMatch(ua, @"GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC(.Flyer|\\_Flyer)|Sprint.ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos.S7|Dell.Streak.7|Advent.Vega|A101IT|A70BHT|MID7015|Next2|nook", RegexOptions.IgnoreCase)) || (Regex.IsMatch(ua, "MB511", RegexOptions.IgnoreCase)) && (Regex.IsMatch(ua, "RUTEM", RegexOptions.IgnoreCase)))



    {



        ret = "tablet";



    }



    // Check if user agent is unique Mobile User Agent



    else if ((Regex.IsMatch(ua, "BOLT|Fennec|Iris|Maemo|Minimo|Mobi|mowser|NetFront|Novarra|Prism|RX-34|Skyfire|Tear|XV6875|XV6975|Google.Wireless.Transcoder", RegexOptions.IgnoreCase)))



    {



        ret = "mobile";



    }



    // Check if user agent is an odd Opera User Agent - http://goo.gl/nK90K



    else if ((Regex.IsMatch(ua, "Opera", RegexOptions.IgnoreCase)) && (Regex.IsMatch(ua, "Windows.NT.5", RegexOptions.IgnoreCase)) && (Regex.IsMatch(ua, @"HTC|Xda|Mini|Vario|SAMSUNG\-GT\-i8000|SAMSUNG\-SGH\-i9", RegexOptions.IgnoreCase)))



    {



        ret = "mobile";



    }



    // Check if user agent is Windows Desktop



    else if ((Regex.IsMatch(ua, "Windows.(NT|XP|ME|9)")) && (!Regex.IsMatch(ua, "Phone", RegexOptions.IgnoreCase)) || (Regex.IsMatch(ua, "Win(9|.9|NT)", RegexOptions.IgnoreCase)))



    {



        ret = "desktop";



    }



    // Check if agent is Mac Desktop



    else if ((Regex.IsMatch(ua, "Macintosh|PowerPC", RegexOptions.IgnoreCase)) && (!Regex.IsMatch(ua, "Silk", RegexOptions.IgnoreCase)))



    {



        ret = "desktop";



    }



    // Check if user agent is a Linux Desktop



    else if ((Regex.IsMatch(ua, "Linux", RegexOptions.IgnoreCase)) && (Regex.IsMatch(ua, "X11", RegexOptions.IgnoreCase)))



    {



        ret = "desktop";



    }



    // Check if user agent is a Solaris, SunOS, BSD Desktop



    else if ((Regex.IsMatch(ua, "Solaris|SunOS|BSD", RegexOptions.IgnoreCase)))



    {



        ret = "desktop";



    }



    // Check if user agent is a Desktop BOT/Crawler/Spider



    else if ((Regex.IsMatch(ua, "Bot|Crawler|Spider|Yahoo|ia_archiver|Covario-IDS|findlinks|DataparkSearch|larbin|Mediapartners-Google|NG-Search|Snappy|Teoma|Jeeves|TinEye", RegexOptions.IgnoreCase)) && (!Regex.IsMatch(ua, "Mobile", RegexOptions.IgnoreCase)))



    {



        ret = "desktop";



    }



    // Otherwise assume it is a Mobile Device



    else



    {



        ret = "mobile";



    }



        return ret;



}




The code above covers a very exhaustive list of devices/browsers/OS which are available. This is a reengineered version of Categorizr(A device detection script) provided with premium version of 51degrees.mobi



The function provided above uses RegEx library to find the matching content in the Browser User Agent string and based on the match it returns the device type as string. The Code below calls the GetDevice function to get the device type string to the ContextCondition as either tablet, mobile or tv.





DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("tablet")



{



   ContextCondition = (context => GetDeviceType(context.GetOverriddenUserAgent()) == "tablet")



});



DisplayModeProvider.Instance.Modes.Insert(1, new DefaultDisplayMode("tv")



{



   ContextCondition = (context => GetDeviceType(context.GetOverriddenUserAgent()) == "tv")



});



DisplayModeProvider.Instance.Modes.Insert(2, new DefaultDisplayMode("mobile")



{



   ContextCondition = (context => GetDeviceType(context.GetOverriddenUserAgent()) == "mobile")



}); 




This is just a small sample of the Display Mode Provided packaged with ASP.NET MVC 4, other links which might help you in understanding the overall concepts are:



References:



http://www.campusmvp.net/displaymodes-in-mvc-4/



http://msdn.microsoft.com/en-us/library/system.web.webpages.displaymodeprovider(v=vs.111).aspx



Sample project with the implementation can be downloaded from here:



https://docs.google.com/file/d/0BzIjFd_Ps-MSQThrTklrbXZOQlU/edit?usp=sharing

Share:

Wednesday, 14 November 2012

My Top 8 picks for Microsoft.NET Architects (ASP.NET MVC)

Past few month was very hectic for me, now since I have some time for myself I am sharing the list of articles which I am going through, these articles are basically related to architecting .NET application using ASP.NET MVC. I hope you will find these links useful for you too.

  1. Of course not to mention GoF Design Pattern Tutorial: http://www.dofactory.com/Patterns/Patterns.aspx
  2. On the same line as above, this link elaborates the patterns by GoF as Illustrated GOF Design Patterns in C# Part I: Creational: (Series Article)http://www.codeproject.com/Articles/3130/Illustrated-GOF-Design-Patterns-in-C-Part-I-Creati
  3. A N-Tier Architecture Sample with ASP.NET MVC3, WCF, and Entity Framework : http://www.codeproject.com/Articles/434282/A-N-Tier-Architecture-Sample-with-ASP-NET-MVC3-WCF
  4. Design pattern – Inversion of control and Dependency injection by By Shivprasad Koirala: http://www.codeproject.com/Articles/29271/Design-pattern-Inversion-of-control-and-Dependency
  5. LINQ and WF Based Custom Profile Provider for ASP.NET 3.5, this article demonstrates Microsoft Provider Pattern using Workflow Foundation: http://www.codeproject.com/Articles/31308/LINQ-and-WF-Based-Custom-Profile-Provider-for-ASP
  6. patterns & practices Application Architecture Guide 2.0, Microsoft Link from where you can download free eBook, Microsoft Application Architecture Guide – by J.D. Meier, Alex Homer, David Hill, Jason Taylor, Prashant Bansode, Lonnie Wall, Rob Boucher Jr, Akshay Bogawat : http://apparchguide.codeplex.com/ or direct Link to download the eBook: Download the final release in PDF on MSDN, either you can download the pdf from this link or you can read the same book online at the link: http://msdn.microsoft.com/en-us/library/dd673617.aspx
  7. Architecture Guide: ASP.NET MVC Framework + N-tier + Entity Framework and Many More : http://www.codeproject.com/Articles/70061/Architecture-Guide-ASP-NET-MVC-Framework-N-tier-En
  8. Security is the most important aspect of any application specially when you are dealing with financial intuitions, even the best of the architecture is good-for-nothing if is is not secure. This is the link of top 10 Security vulnerabilities provided by Open Web Application Security Project, a non-profit charitable organization and elaborated with solution by Troy Hunt: OWASP Top 10 for .NET developers part 1: Injection : (Series Article) http://www.troyhunt.com/2010/05/owasp-top-10-for-net-developers-part-1.html , same is available for download as pdf eBook from  : http://asafaweb.com/OWASP%20Top%2010%20for%20.NET%20developers.pdf

This list is open for comments, so go ahead and suggest me if you have good links which I can add to my top 8 and in the same line. Thanks.

Share:

Monday, 12 November 2012

Free Microsoft Learning Events by Microsoft Learning Partners

Click on the link below to find some of the third-party events where you can learn about Microsoft technologies.

http://www.microsoft.com/learning/en/us/community/events.aspx

Microsoft Tech Showcase: Technology events hosted by Microsoft Learning Partners

You can search events based on your technology, country, City/Province, Online/In Person events, From Date, To Date and name of the partners. These events will help you to boost your careers, learn new technologies, etc all free of cost.

Share:

Tuesday, 6 November 2012

Debugging .NET code using Devices(iPad/iPhone) and Fiddler

While working on programs which are targeted for devices (mobile, tablets, etc) we often face a situation where we feel that just device simulators are not enough I wish if I could run my programs in debug mode using the physical device. And this scenario often arises because personally I too faced a scenario where I was able to run my website on the simulator without any issues but the same was not working as expected on the physical device.

So in this post I am going to show you how to debug the .NET codes using apple iPhone or iPad. To do this  you

  • First need to configure Desktop or Laptop computer where you are running your .NET code
  • Second Configure Devices iPhone or iPad

There are few perquisites which are required

  1. Of course a apple (iPhone or iPad) device which can be used to debug the codes, you can also use Andriod phones but ad hoc connections are not supported by default on Andriod phone.
  2. WiFi enabled on your PC with administrator privileges, you can either enable you Internet connection sharing on WiFi network or created a ad hoc network, details of which I am going to mention later.
  3. If you are going for ad hoc network you may need a proxy server installed on your PC, here I am going to use Fiddler, you can download from here: http://www.fiddler2.com/fiddler2/version.asp
  4. Visual Studio installed, I am going to use Visual Studio 2012 in this article, but this post holds good for any version of Visual Studio as long as it can support debugging.

In this post I am going to show connecting using iPhone/ iPad using ad hoc network using my Fiddler.

Now lets get started step by step starting from configuring my system to configuring the phone device.

Creating a ad hoc network

  1. Open Network and Sharing Centre (Control Panel\All Control Panel Items\Network and Sharing Center).
  2. Go to Manage wireless network –> Add, this will open a Popup screen where either you can Manually create a network profile or you can Create an ad hoc network

image

3. Once you get the following screen, you can enter the name of the ad hoc network of your choice, select WEP as Security type, give the Security key and select the checkbox to Save the network, as given in the screen below.

image

Now you system is almost ready to accept incoming connection through the wireless network devices, just make sure your wireless is turned on, go to the taskbar network icon and open the window, this will display the newly created ad hoc network by you as Waiting for users. 

image

Now since your network is ready to accept incoming connections I am going to set up my proxy server where I am going to use Fiddler. To configure Fiddler open the fiddler in your system, Go to Tools –> Fiddler Options –> Navigate to Connections Tab select the check boxes as given in the screenshot below and leave the port as default 8888 if not already in use in your system, this can be changed as required.

image

Now since your system is ready for device connection, the only thing left is configuring your device. To configure your device follow the following steps.

In your iPhone or iPad first go to Cellular Data settings this is applicable if you are using your network provider internet connection. Once you open this Cellular Data tab in your device, disable the cellular data as given in the screen below..

iPadDeviceiPhoneDevice1

Now its time to configure your Network Settings in iPad and iPhone

iPadDevice3

iPhoneDevice2iPhoneDevice3

In the screen above you have to configure your device to use Static IP Address, with the IP Address which should be in the same network address and subnet address. You just need to give some unused class D address which should be different from your system to which this is connecting. You can check your system IP Address of Wireless LAN adapter using ipconfig command in command prompt. This IP address will be the IP Address of the device (iPad/iPhone).

Now go to the HTTP Proxy settings on the same page below of device network settings, select the proxy settings as Manual. In the Server you have to enter the correct IP Address of the wireless LAN adapter of your system (Desktop/Laptop), enter the port which was configured on Fiddler as given in the fiddler settings above.

Once you have completed these settings your device is also ready to connect to the System. Once connected you can see the status as connected instead of Waiting for users in ad hoc network.

Now once everything looks fine, you can go ahead and first run the application in debug mode in your system, once your application opens in the web browser you can get the URL address on which your application is ready for debug. As per my convenience I have used a MVC application for debugging, but you can use any other types of web application also.

iPad1

Enter the Same URL (http://localhost:35510/) in your device. I have kept a line of code which gives me the UserAgent from where the request is coming from.

string userAgent = HttpContext.Request.UserAgent;

Following are the screens which I get in iPad and iPhone respectively

iPhoneDevice4   iPadDevice2 

Now if I go and set the breakpoint in the code, I can see the user agent which clearly shows the requested client user agent.

iPhone2Laptop

iPad2Laptop

In the above two screens you can see the user agent browser as Mozilla/5.0 (iPhone…) and Mozilla/5.0 (iPad…) for iPhone and iPad respectively.

Note: IP addresses are used in this article are just for illustration only, this is not directly or indirectly related to any existing IP address used anywhere in existence.

Hope this helps.

Share: