![](/img/trans.png)
[英]How to recognize the view.cshtml that you are coming from using ASP.NET Core MVC?
[英]Using .net core, how can i show the html content coming from database on view
我有在Global.asax
文件的Application_BeginRequest
方法中編寫的業務登錄,其中我從數據庫獲取html內容並使用文字控件在視圖中設置內容。
現在我將項目遷移到.net核心,我想要像上面提到的那樣做。 我使用middleware
在代碼中獲得了html內容,但現在我試圖在視圖中顯示內容但無法這樣做。
以下是我的模特
@model string
<div id="content">@Model</div>
我正在回來
return View(html);
作為一個字符串。
我的問題是,我想知道如何使用.net核心顯示來自數據庫的html內容的步驟。
得到了解決方案。 我錯過了模特。 我聲明了模型,然后將該模型傳遞給視圖,然后在視圖中使用@Html.Raw(@Model.Property)
來呈現HTML。
謝謝@adem caglin。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.