How-To's

ASP.NET 4.5 and ASP.NET MVC 4 Support in ReSharper 7

In spite of all the wonderful things happening in the Windows 8/WinRT world, ReSharper continues to provide support for existing technologies such as ASP.NET. In the latest release, ReSharper is augmented with new features for supporting ASP.NET 4.5 and ASP.NET MVC 4. Here’s what we’ve got in store.

ASP.NET 4.5

In ASP.NET 4.5, Web Forms support includes several improvements when working with data. Here are the ones that ReSharper now understands and supports:

  • Strongly Typed Data Controls — instead of using Eval() and Bind() for data binding, ASP.NET 4.5 lets developers declare the type of the element being bound via the ItemType property and provides the Item and BindItem properties inside binding expressions. ReSharper provides full support for these new constructs with code completion:
    ReSharper code completion for strongly typed data controls
    Inspections, fixes, refactorings and other typical ReSharper features are also supported:
    Code inspection for data binding

  • Model Binding — this mechanism lets one bind controls to data acquired from a particular function on the page, defined in the SelectMethod property. Once again, ReSharper provides typical features such as code completion…
    ReSharper code completion for model binding
    … as well as navigation, refactorings and other features typical for a C# property. Additionally, ReSharper is smart to check the return type of the SelectMethod and issue a warning if its type does not match that of the ItemType:
    ReSharper issues a warning it SelectMethod parameter type doesn't match that of ItemType

  • ReSharper is now also aware of HTML Encoded Data-Binding Expressions, which let developers add a colon (:) to the <%# prefix to ensure the subject of a data binding expression is HTML-encoded.

Of course, ReSharper also supports typical features such as code completion and validation inside the string literals that are used in the Eval() and Bind() methods.

ASP.NET MVC 4

ReSharper 7 extends its support for ASP.NET MVC to projects that use the ASP.NET Web API — the new framework for creating HTTP services. This means typical features such as inspections, navigation and refactorings are now available for Web API projects.

In addition, ReSharper now supports the Display Modes feature of MVC4, which lets an application select views depending on what browser makes the request. For example, ReSharper’s Go to Declaration on a view reference will show all the view files with different display modes:

ReSharper navigation support for ASP.NET MVC 4 Display Modes

In a similar fashion, performing a Find Usages on a view file with a display mode suffix will correctly locate its usages. Also, ReSharper is smart enough to detect when custom display modes are defined.

We hope you find these new ASP.NET-related features beneficial in your everyday development. Meanwhile, we continue to add more goodness to our support of the ASP.NET stack. Stay tuned for more!

image description