4

Including Pre-Compiled Views in an ASP.NET MVC Web Application

Reference

please see above blog. am trying to create class library of user control in MVC 3. with reference to above blog i have created class library write view in it. but problem is how to register that view in my consumer application as partial view. PrecompiledMvcEngine is not found in nuget. which will register precompiled view in asp.net MVC application.

Give me an example how to do it?

1 Answer 1

4

Basically you need to register a virtual path provider

  1. You must register a VirtualPathProvider in the Global.asax Application_Start handler.
  2. You must call the view in your DLL using the special path like so: return View("~/foldernameofdlllocation/nameofdll.dll/nameofview.cshtml");

To help track down the location of your view within the dll use something like reflector or telerik's JustDecopile (Free).

This blog post may be useful for you:

http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/

This Question may also be of use:

Using VirtualPathProvider to load ASP.NET MVC views from DLLs

Code Sample from blog post:

http://www.wynia.org/download/aspnetmvc-plugin-poc/POC.MVCPluginDemo.zip

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.