There are so many productive tools and packages out there that can be used for profiling an ASP.NET MVC application. While back I wrote a quick intro about how Glimpse can come handy profiling your web application. There is one more simplistic and quick way to start profiling load / execution time for your application routines using MiniProfiler. This little package is prepared by folks at Stackexchange and used for Stackoverflow.com and other sites. MiniProfile's homepage shows quick way to get started with using MiniProfiler in your application. Following code snippet is required to profile a piece of code (not to forget MiniProfiler.Start() and MiniProfiler.Stop()): var profiler = MiniProfiler.Current; using (profiler.Step("Set page title")) { // Your code to profile } and you will see something similar to following when you load your application and run through profiled piece of code: So if I need to profile the execution » Read more

 Jsinh        

The brand new version ASP.NET 5 (a.k.a ASP.NET vNext) can be developed and hosted on all three major platform - Windows, Linux and MacOS. Getting started with ASP.NET 5 (TODO: Link to be updated with new Post for .NET tools) is not so hard after all and is definitely fun to play early. The biggest break through that comes to .NET and ASP.NET world is the capability to write and host anywhere. Yes you can now develop and host a ASP.NET Web application - MVC or WebAPI even SignalR on any platform - Windows, Linux and MacOS. This has always been the de-facto standard for windows since long using Visual Studio (prior VS2015) but it can be fun on Linux and MacOS also using your favourite editors or Visual Studio Code. Following step needs to be performed on a brand new spinning Linux » Read more

 Jsinh        

Microsoft and Visual Studio team announced release of Community Technology Preview 5 (CTP 5). Download: Visual Studio 2015 CTP5 This version of visual studio brings lots of improvements / better integration and bug fixes for ASP.NET (ASP.NET 5 vNext version). Some of the highlighted features, changes and fixes released with this version of Visual studio: XAML langauge service rebuilt on top of .NET Compiler Platfor ("Roslyn"), fast and reliable XAML editing experience with intellisense. Timeline tool - New UI Performance Analysis Tool for WPF Applications Improvements to IntelliTrace in Visual Studio Ultimate 2015 Improvements to Diagnostic tools debugger window Announcing TypeScript 1.4 Tons of improvements and bug fixes for ASP.NET 5 - Beta 2 This is a good oppurtunity to try out the new features that will be part of Visual Studio 2015 (the name might change). » Read more

 Jsinh        

Note: [Deprecated Content] This was written while ASP.NET and .NET Core was in beta (around beta5 or beta6). Since then a lot of stuffs have changed and moved around. Stuffs described below may or may not be true for current stable releases of ASP.NET Core. I recommend not to follow along and get confused. Use official configuration documentation that explains it correctly - docs.asp.net Along with the new version ASP.NET 5, comes some small goodies that are worth taking look at. One of those tiny but powerful enhancment currently experimented in ASP.NET 5 (still in BETA at the time of writing, may change) is the way to control exception / error detail displayed to end user and showing full stack trace and additional information when the developer is working. If you have given a try to the default template - "ASP.NET 5 Starter Web" » Read more

 Jsinh        

Not blogging yet? Around 1.5 years back, I wrote a post about what i call Slumdog Blogging, and I think you should read it. I learned a few things during my blogging journey and reading around which I would like to share today. Choose your seat and stick to it. I started blogging in late 2011 on URL: jsinh.in. At the time of starting I never thought of other things I might like to do with the domain. In few years I decided to put out a page or two where I can meta-link to well-known sites where I can be found. This was with the intention to give "More information" links to people who are interested in what I do or I don't. This would be about me and more direct, blogging content and articles is about what I write or wrote and shared with the community. » Read more

 Jsinh        

Please note: [Deprecated Content] This article is outdated now and lot of things have changed since it was written. Please refer / read to the newer version of the related article instead of the content below. Also follow along and learn about the latest bits on official ASP.NET Core documentation Thanks! In case you missed the big news, then its time to say 'Hey to K (KAY)' (i just made it up). Recently Microsoft announced .NET as Open Source with .NET 2015, ASP.NET 5 (vNext), ASP.NET Web Development on MAC and LINUX platform and the biggest of all Visual Studio IDE Community SKU (Visual Studio for Everyone - FREE). Leaving behind the closed group development practices and proprietary line of products, Microsoft is finally taking big step to embrace the open source way and community driven development. I feel very excited to see this happening already and » Read more

 Jsinh        

If you are not using Glimpse to debugging and profiling ASP.NET web application then you are missing out on very useful stuff I must say. This NuGet package brings many handy information about your ASP.NET MVC application, which in turn can be useful and quick help to dig state and performance issues in your application. Advantage of adapting Glimpse is that, it can be used in production environment where it can be enabled or visible based on your custom configuration / conditon. Thus gives you power to analyse your production state without compromising or hindering your environment rules and constraints. You can install Glimpse from NuGet into your ASP.NET MVC application with Install-Package Glimpse.Mvc5 (because I am using MVC5 for this example). This installs three packages: Glimpse.Mvc5 (Current release is 1.5.3) Glimpse.AspNet Glimpse (Core) If you are using other version of MVC you » Read more

 Jsinh        

When you design your table, you choose to add a primary key constraint for one or more column while create the same. Column attached with primary key constraint should contain UNIQUE and NOT NULL values. We all know that. But PostgreSQL does not force this constraint while creating a new table, you might forget to add one (missing morning coffee may be). I tried creating a table without adding primary key constraint in PostgreSQL CREATE TABLE weather ( city character varying(80), temp_lo integer, temp_hi integer, prcp real, date date ); This took off and created the weather table successfully. Now when I tried to view data (which I inserted after creating the table) using pgAdmin III, it displayed hint (warning, I would say) as Edit table data without primary key This warning message say, I will not be able to edit or change existing row data since I do » Read more

 Jsinh        

Once you have your PostgreSQL database server installed, up and running, due to security reasons by default remote access to connect with your database instance is disabled. If you try connecting with your PostgreSQL database server from client machine, you will encounter error. could not connect to server: Connection refused (0x0000274D/10061) Following screenshot displays error I received when trying to connect from a windows client machine using pgAdmin III Following below steps you will be able to enabled remote access to PostgreSQL database server. Before even we start it is important to know that there are two configuration files (and others) which control how your database server works. This configuration files contains settings that needs to be tweaked or changed to make your database instance run as per your needs. postgresql.conf (Used to set various parameters that affect the database) pg_hba.conf (Used to control client authentication, » Read more

 Jsinh        

Ok so you know the blah blah of how PostgreSQL is awesome relation database (RDBMS) and great for reliable transactions, good for so many things, lots of enterprise features and gives concurrency without read locks and stuffs. If you are not aware of this RDBMS, then I would recommend you search for advantages of using PostgreSQL and what is served in its plate. PostgreSQL is pronounced mostly as "post gray sequel" or "post ge are ee as que el" (I am sounding very dramatic here). Back to the post now, Fire up your Ubuntu 14.04 to start the installation. It would almost follow the same for most of the Ubuntu flavors out there. First step - you know the drill :) sudo apt-get update Next step: sudo apt-get install postgresql postgresql-contrib postgresql installs the core PostgreSQL engine and RDBMS around which everything else is build. The core files for this » Read more

 Jsinh        

While using NuGet for installing, updating and maintaing libraries into your projects, you would have encountered following error: Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first. Following error was encounted when I tried to update Entity Framework NuGet package in one of my project To resolve this issue quickest way is to open the Package Manager Console window in visual studio, which will initialize the powershell execution context for NuGet packages to use. You can open up the package manager console from top menu in visual studio - View > Other Windows > Package Manager Console If the problem still persists then you can close all instance of Visual Studio currently running and then open up Windows Powershell in administrator mode and fire following command: Set-ExecutionPolicy AllSigned Type Yes to confirm - change in » Read more

 Jsinh        

Microsoft OS (XP or later) and .NET provides finest way to secure your data for storage and in-memory. This can be accomplished using following classes from Data Protectection API ProtectedData ProtectedMemory Above mentioned classes can be found in System.Security.Cryptography namespace. Also known as part of DPAPI, they are available since .NET 2.0 ProtectedData ProtectedData can encrypt and decrypt your data symmetrically. To encrypt data following code is used: ProtectedData.Protect(byteArrayOfOriginalData, additionalEntropyOrSalt, DataProtectionScopeValue); To decrypt data following code is used: ProtectedData.Unprotect(byteArrayOfEncryptedData, additionalEntropyOrSalt, DataProtectionScopeValue); In above code snippets additionalEntropyOrSalt can be some custom key / salt value / entropy data that you can add to the encryption / decryption process to increase security strength. DataProtectionScope in above code snippets can have any of the two values: CurrentUser - Allows decryption of encrypted data in current user context only. LocalMachine - Allows decryption of encrypted data in current machine context » Read more

 Jsinh        

You would have used ClickOnce deployment / publishing technique for your projects at some point. If not then I would recommend it as it serves as web based installer / setup with minimal configuration and very easy to learn / maintain and push updates. You can publish your project and host the deployment package on Web Server. Typically you would do it on an IIS web server. IIS web server by default understands the artifacts of ClickOnce package and contains MIME types that allows this package to be requested or installed for web server. But you are not limited to IIS web server and can host this package on any web server. For example - Apache or Nignx (on Ubuntu). These web server does not know about the file types / MIME types of click once package so you need to take care of one extra step to make it work. Following is the » Read more

 Jsinh        

Recently one of my family member ran into trouble when trying to fill an admission form online. As part of this form filling process, we had to upload scanned copies of previous study's merit sheet. We got it scanned but the scans where big in size. One of the scan image was around 2.5 MB. The online form filling site only allowed maximum 900 KB of file size to be uploaded. The way to compress or reduce size of an image is using Microsoft Office Picture Manager. This program / feature is part of Microsoft Office 2010 and prior editions. For some reason this program is been discontinued and is not part of later versions of Office packages. You can download this as part of Microsoft SharePoint Designer 2010. As an example I have a minions-party.jpg file which around 1.35 MB on disk. While installing Microsoft SharePoint Designer » Read more

 Jsinh        

I guest most of us are using cloud storage for taking backup of our precious data. No you say? Then my friend you will be in big trouble soon and you will repent for this act. I have lost few of my precious data in past because of this mistake and from that day I have never skipped taking backup of my data every week. Local hard disk can fail anytime, no one can give any gaureentee for that for sure. Anything stored on cloud is fail safe and secure unless you decide to share it to public. One thumb rule you should follow for all your important data is always backup your data at least at three different place. Primary storage where you keep it and access it daily or easily available. Take a backup to a local detachable - portable drive or something. This is your local quickly » Read more

 Jsinh        

Not a long post but very handy query that can be used when you need to know the installed SQL Server product's version, edition, flavour, server name details. SQL Query to get version details for installed Microsoft SQL Server: SELECT SERVERPROPERTY('productversion') AS 'Product Version', SERVERPROPERTY ('productlevel') AS 'Product Level', SERVERPROPERTY ('edition') AS 'Product Edition', @@SERVERNAME AS 'Server Name', SUBSTRING(@@VERSION, 1, CHARINDEX('-', @@VERSION) - 1) + CONVERT(VARCHAR(100), SERVERPROPERTY('edition')) + ' ' + CONVERT(VARCHAR(100), SERVERPROPERTY('productlevel')) AS 'Server Version'; Following query shows below output on my test machine: Happy coding !! » Read more

 Jsinh