我是mvc的初學者。當我將項目升級到MVC6時,我遇到了一些問題,也無法找到解決方案。我的代碼塊是:如何在MVC6中使用HtmlTextWritter
public static void WriteTo(HtmlHelper helper, string value)
{
var baseWriter = helper.ViewContext.Writer;
using (HtmlTextWriter textWriter = new HtmlTextWriter(baseWriter))
{
textWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
textWriter.RenderBeginTag(HtmlTextWriterTag.Script);
textWriter.Write(value);
textWriter.RenderEndTag();
}
}
如果有任何的方式來實現MVC6相同的情況下(如使用HtmlTextWritter的),或者如果在我的代碼任何差錯block.can請你提出解決方案。即使用谷歌嘗試,但我不能得到選擇解決方案。
@thanks CodeCaster:任何替代方法來實現這種情況? – Riowan