Tuesday, February 21, 2012

Integrate Bing Searchbox in MVC3 with razor application

0 comments
If you are building MVC3 application with razor view engine then now it is very easy to integrate Bing Searchbox in just 2 steps as per below.

1) Add Microsoft Web Helpers
In your MVC application just add this helper's reference using Nuget Command


2) Add below code to cshtml Page


and output of this will look like as per below


You can also add Twitter Feeds, Facebook Feeds using this helper, to read about how to do this refer this link.
To read more about Microsoft.Web.Helpers refere msdn link.



Add Elamh to ASP.NET MVC application

0 comments
Elmah is great open source module developed by Atif Aziz to handle error logging for asp.net application and there is nuget pacakge also available to add in to existing application. If you are new to Elmah then visit my previous post to started with it.

Alexander Beletsky has developed Elmah.Mvc for asp.net mvc application it is also available through Nuget package.
You can add it by GUI tool as per below
Go to Reference> Manage Nuget Pacakge > Search Elamh.MVC


OR By Package Manager console as per below

Now Hit admin/elmah with your app's URL,you will get elmah page. That's it!

Please refer Author's blog post about what are the changes in this MVC version of Elmah.



Monday, February 20, 2012

Paging sorting with WebGrid in MVC3 and razor

0 comments
If you have worked with MVC3 and Razor view engine then you may be aware that when will you create new view for details on bases of IEnumerable Model then it
it will create cshtml code with foreach loop which will cause to render data in Grid Format as per shown in below fig.


Now if you want Paging and sorting to this data then manually you need to make lots of efforts to achieve desired result.
But Microsoft has already built very good helpers called WebGrid, to achieve this so you do not need to do that manually.
So it will look like as per below after replacing above code.


If you notice URL in above fig then you can see that it WebGrid will automatically make sorting request with proper parameter you can also change parameter
name to customize URL,e.g.
var grid = new WebGrid(Model, canSort: true, canPage: true, rowsPerPage: 2,sortFieldName:"S", sortDirectionFieldName:"SD");

You can apply style to particular column by style: attribute. http://stackoverflow.com/questions/9357786/apply-specific-width-in-column-of-webgrid-in-mvc3


Look at



Saturday, February 18, 2012

Look at ASP.NET MVC4 Beta!

0 comments
Microsoft has released ASP.NET MVC4 Beta officially and Jon Galloway announced regarding of it in his blog with introduction to ASP.NET web API.

Top Most Features
  •     ASP.NET Web API
  •     Refreshed and modernized default project templates
  •     New mobile project template
  •     Many new features to support mobile apps
  •     Recipes to customize code generation
  •     Enhanced support for asynchronous methods
Also you can build ASP.NET MVC project with Nuget Package
For more details and installation tips look at http://www.asp.net/mvc/mvc4



Thursday, February 16, 2012

Swap VIP in Window Azure

0 comments
Swap VIP is very good feature available in Window azure, I would like to described here about that with good reference link.

What is SWAP VIP ?
There are 2 type of environment on which you can deploy on window azure application.

Staging
In other word you can say testing environment, having similar configuration as per production. Before deploying to production (where actual user will use your application) you can deploy to staging to fix bugs, test security issues, configuration problem etc.

Production
It is actual environment where you can move tested staging application which will be used by real users. (you can directly deploy your application if you are confident on your testing!!)


In sort Swap VIP is azure feather to move application from staging to production by just one click!

How to use Swap VIP?
After testing your application just click on Swap VIP as per shown in above fig.and click ok and it will transfer from staging to production with zero downtime of your original application!

What will happen while swapping?
If you have notice DNS when you have created staging would be as per below.
ID + Cloudapp.net

and in production DNS would be actual URL with something like myapp.cloudapp.net
When you going to swap azure will just transfer this DNS entry.

Reference Links