Wednesday, December 5, 2012

"Add Web Reference" missing in Visual Studio 2010/2012 - Solution

Where is the Add Web Reference option in Visual Studio 2010 and 2012.

Did microsoft remove the option to add web service and retained option only to use WCF references (Service Reference) ?

Everytime Microsoft comes up with a new version of a product, some of the options are either renamed or rearranged.

The same happened with Visual Studio 2010.
The option to add web reference is still available but is misplaced.

To access the option follow the steps below:

1) Right Click the Project -> Select "Add Service Reference". You get the "Add Service Reference" window.
2) On its left bottom there is an "Advanced..." button. It will take you to the "Service Reference Settings" window.
3) Bottom left of this window there is the old "Add Web Reference..." button dumped in a corner.
Click to get the "Add Web Reference window".


Monday, December 3, 2012

How to declare local variable in ASP.NET MVC Razor?

How to declare local variable in ASP.NET MVC Razor?
This is a very common scenario that newbies in ASP.NET MVC Razor view comes across.
It would be confusing when even with the "@" sign before the declaration it doesn't work.

The solution as simple as placing the whole declation statement inside curly braces.
Even multiple declarations can be placed inside a curly braces block.
The declaration and usage would be as below.

@{int count = 1;}
@foreach (var step in level.steps)
        <span class="title">@step.Name</span>
        <span class="meaning">@step.Description</span>