我是从asp迁移网站ASP.NET MVC
i am migrating a website from asp to asp mvc
在asp网站还有很多地方,他们有文字标签和服务器在文字标签生成一串HTML和棍棒的。
in the asp site there are many places where they have "literal" tags and the server generates a bunch of html and sticks in in the literal tag.
什么是在asp的MVC doign此相当。我应该在ViewData的推呢?
what is the equivalent of doign this in asp mvc. Should i shove this in ViewData?
推荐答案相当于是不会犯同样糟糕的设计选择原来的开发商的。
The equivalent is to not make the same bad design choices the original developer made.
但是,因为我们生活在现实世界中,你会推自己的字符串,其中包含中,HTML到presentation型号为某一特定页面,然后将其写入响应流中。
But, since we live in the real world, you'd shove their strings-which-contain-html into the presentation model for a particular page and then write it to the response stream.
在你的模型:
public class MyPageModel { public string HolyCrapItsHtml {get;set;} }在你的控制器:
public ActionResult MyPage() { return View(new MyPageModel {HolyCrapItsHtml = OldCode.GetHtmlICantBelieveIt()}); }和在你的页面:
<div> In the olden days, we'd concatenate our webpages together from strings like: <%= Model.HolyCrapItsHtml %> </div>更多推荐
什么是等价的&QUOT;字面&QUOT;标签在asp.net mvc的
发布评论