How can I get .cshtml from Database dynamically

2019-04-10 02:46发布

I have to say: This is a different question from these:

I want to provide dynamic .cshtml Content from db when i want.

Example:

City Table,FreeHtml Column

@model City 
@Html.CheckBox - @Model.Name - @Html.CustomHelper

How can I write as html helper:


@model City
@Html.RazorRaw(Model.FreeHtml,Model)

or as CustomViewResult


public RazorPartialViewResult CityHtml(City city)
{
   return new RazorPartialViewResult(city.FreeHtml,city)
}

1条回答
可以哭但决不认输i
2楼-- · 2019-04-10 03:25

I think your answer is here: Storing ASP.Net MVC Views in the Database

You need to replace the default view engine(s) with a custom one. Here is an example: http://weblogs.asp.net/imranbaloch/archive/2011/06/27/view-engine-with-dynamic-view-location.aspx

查看更多
登录 后发表回答