1

Does anyone have any idea how to create and package redistributable components for MVC3/4 websites, just like we had User controls etc with Web forms where a piece of functionality along with its UI and business logic could be modularized, packaged and reused in various other contexts, how does one go about doing this in MVC without actually sharing their source code, if it is even possible. Thanks

2 Answers 2

2

You can do this using the RazorGenerator Visual Studio extension (http://razorgenerator.codeplex.com/). The documentation is quite complete but you essentially need to set the Custom Tool property on each of your views to "RazorGenerator", which generates a "[viewname].generated.cs" file (similar to the designer file in WebForms). This then compiles into your project's DLL, and you can then reference the DLL in other projects/contexts and use the compiled views in the same way as you use the project's own views. I've used this extensively in one of my projects where I defined a whole suite of Editor and Display templates and used them against my strongly typed models.

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

1 Comment

Thanks this looks exactly like what I want.
1

You're probably searching for a MVC view user control

you can find an example here or a simple google search for MVC view user control gives you alot of examples

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.