Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 24, 2012 01:46 AM by Young Yang - MSFT
May 17, 2012 07:29 AM|LINK
Is it possible to store and then retrive MVC tags inside a database?
Suppose I want to store a link like this one - @Url.Action("link text", "SomeAction", "HomeController) - in an NVARCHAR field in my database. How do I code this in Razor so that it will produce a link pertaining to that example?
May 17, 2012 07:44 AM|LINK
I think It can be done using Razor.Parse with Your razor syntax as string.
May 17, 2012 08:26 AM|LINK
Thank you for the suggestion. I am very new to this. Yet I still tried it. But it just added an ";" to the last part of the supposed output.
What I did was installed the RazorEngine and then in my view I coded : @RazorEngine.Razor.Parse(item.contentFromDatabase)
Or maybe I just coded it wrong.
May 24, 2012 01:46 AM|LINK
You need to write a custom
VirtualPathProvider and register it within the ASP.NET hosting environment. There is an example that does exactly what you're looking for:
http://www.umbraworks.net/bl0g/rebuildall/2009/11/17/ASP_NET_MVC_and_virtual_views and you also could refer to:
Hope this helpful