Posts Tagged ‘.NET’

ReSharper and custom ASP.NET MVC view location

Tuesday, January 29th, 2013

Since ReSharper 5, we’ve had splendid support for ASP.NET MVC. One of the features included for ASP.NET MVC is Navigate to View and Create View. When working in an ASP.NET MVC action method, these methods allows us to either navigate to the corresponding view or create a view with the correct name at the correct location.

The interesting part of this feature is that ReSharper checks for assignments to the different properties on a ViewEngine, such as ViewLocationFormats and PartialViewLocationFormats, to determine the paths to various view types. This means it is possible to diverge from the default conventions in ASP.NET MVC and still make use of the ASP.NET MVC support ReSharper gives us.

Imagine having a project in which views are not located in the conventional Views folder but instead in another subfolder, like UI/MVC/Razor. We can do this in ASP.NET MVC by creating a new ViewEngine implementation and specifying a path template in the constructor:

To ensure ASP.NET MVC makes use of this custom ViewEngine, we must register it in Global.asax under Application_Start:

What’s interesting is that ReSharper immediately tells us no views can be found:

We can now move our views to the correct location or have ReSharper create them for us using the Create View feature. The new view will be located in our project under UI/MVC/Razor/Home/Index.cshtml.

Pretty slick if you ask me!

Announcing ‘Tales From the Development Crypt’

Wednesday, October 29th, 2008

Our .NET products, ReSharper and dotTrace, are being developed as we speak. Yet we do not speak about that enough.

It recently came to our attention that our .NET developers are dying to tell you about the goodies they’ve been able to come up with, design and code. They want to share their heartwarming stories of additional application performance analysis tools, new intelligent context actions and ever smarter null reference handling with, well, anyone who’ll listen.

So, we’ve decided we’ll be bringing you tittillating news bits about dotTrace and ReSharper as they keep coming in.

Stay Tuned!*
  
*Tales From the Development Crypt coming soon to a .NET blog near you.