asp.net-mvc ASP.NET MVC Razor 设计器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4551300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 00:40:00  来源:igfitidea点击:

ASP.NET MVC Razor designer

asp.net-mvcrazor

提问by detroitpro

I am introducing ASP.NET MVC to a new team and one of the questions that comes up often is "Is there a designer view"

我正在向一个新团队介绍 ASP.NET MVC,经常出现的问题之一是“是否有设计器视图”

Even if it's not for layout is there an IN visual studio design view for ASP.NET MVC3 using the razor view engine.

即使它不是用于布局,也有一个使用剃刀视图引擎的 ASP.NET MVC3 的 IN Visual Studio 设计视图。

回答by Erik Funkenbusch

No, there is no designer. It would likely be difficult for a designer to even know what is meant by Razor code in many cases.

不,没有设计师。在许多情况下,设计人员甚至可能很难知道 Razor 代码的含义。

It's really not so difficult to just use your web browser as a viewer. You can make changes to the HTML without having to recompile, just make the change, save, and refresh your browser.

仅将您的网络浏览器用作查看器并不难。您无需重新编译即可更改 HTML,只需进行更改、保存并刷新浏览器即可。

EDIT (8/2/2013)

编辑 (8/2/2013)

Since this answer was originally written, Microsoft has released Visual Studio 2012 which includes a feature called Page Inspector, which while not a true "designer" in the way that the question was written, it does give a much nicer semi-live preview mode. This has been improved in Visual Studio 2013 (which was RTM'd today, 10/17/13).

由于此答案最初是编写的,因此 Microsoft 发布了 Visual Studio 2012,其中包含一个名为Page Inspector的功能,虽然它在编写问题的方式上不是真正的“设计者”,但它确实提供了更好的半实时预览模式。这已在 Visual Studio 2013 中得到改进(今天已 RTM,13 年 17 月 10 日)。

回答by 4ks

I use a web browser window and set the url my localhost in place of the designer. view > "other windows" > "web browser". I then split the windows vertically or horizontaly.

我使用 Web 浏览器窗口并设置 url my localhost 代替设计器。查看>“其他窗口”>“网络浏览器”。然后我垂直或水平拆分窗口。

回答by BraveNewMath

I was able to work using the following trick:

我能够使用以下技巧工作:

  1. change the razor file's extension to .html
  2. Open the document
  3. with the document open, change file extension back to .cshtml
  1. 将 razor 文件的扩展名更改为 .html
  2. 打开文档
  3. 打开文档后,将文件扩展名改回 .cshtml

Congratulations, you now have a designer's view of the razor file. If you need razor intellisense, close and re-open it.

恭喜,您现在拥有了 razor 文件的设计者视图。如果您需要剃刀智能感知,请关闭并重新打开它。

回答by Craig

No, in general you should try and steer clear from visual designers. The combination of HTML/CSS/Javascript is something that just cannot be done well with visual designers and the short term pain of learning these manually will be well worth it. Once you know these well you will be coding in a cleaner and quicker way. I often use Expression Web to do initial layouts before copying it to Visual Studio.

不,一般来说,您应该尝试避开视觉设计师。HTML/CSS/Javascript 的组合是视觉设计师无法很好地完成的事情,手动学习这些的短期痛苦将是值得的。一旦你很好地了解了这些,你就会以一种更清晰、更快捷的方式进行编码。在将其复制到 Visual Studio 之前,我经常使用 Expression Web 进行初始布局。

回答by Eric Bishard

I know I am late to the party, but..

我知道我参加聚会迟到了,但是..

You can trick the IDE as mentioned above, but if you are building applications in MVC, you should be comfortable in code view. It is more productive and most of the responsive design and css implementation can give you false results in design view. Designer is useful in WebForms. But with the Browser Link feature in Visual Studio 2013, there is no longer any reason to trick your IDE, you can have one-to-many browsers open and get live updates back and forth from browser to visual studio. Can't beat that! The browser is where it's at!

如上所述,您可以欺骗 IDE,但如果您在 MVC 中构建应用程序,您应该对代码视图感到满意。它的效率更高,并且大多数响应式设计和 css 实现都可以在设计视图中为您提供错误的结果。Designer 在 WebForms 中很有用。但是使用 Visual Studio 2013 中的浏览器链接功能,不再有任何理由欺骗您的 IDE,您可以打开一对多浏览器并在浏览器和 Visual Studio 之间来回获取实时更新。不能打败它!浏览器就在那里!

Browser Link!

浏览器链接!

Install the following and you will be golden!

安装以下内容,您将成为金子!

Microsoft Visual Studio 2013 Update 3
Web Essentials(Dependent on VS Update 3)

Microsoft Visual Studio 2013 Update 3
Web Essentials(依赖于 VS Update 3)

回答by GraemeMiller

I think they are working on that as a feature for Expression Blend 5 Developer Preview.

我认为他们正在努力将其作为Expression Blend 5 Developer Preview 的一项功能 。

They clearly recognise the issue of designing JS in the designer so I suspect they realise the same applies to some designers working on MVC applications.

他们清楚地认识到在设计器中设计 JS 的问题,所以我怀疑他们意识到这同样适用于一些设计 MVC 应用程序的设计师。

I was told by someone from Microsoft "I think in Blend for HTML, using interactive mode, you would probably be just fine with designing MVC or MVVM patterns"

微软的某个人告诉我“我认为在 Blend for HTML 中,使用交互模式,你可能会很好地设计 MVC 或 MVVM 模式”

Also check out Visual Studio Page Inspectorit looks like it will do what is needed

还要查看Visual Studio Page Inspector看起来它会做需要的事情

In Visual Studio 2013 added browser linkthis allows two way communication between browser and Visual Studio. It means you can refresh browser when you change code and instantly see how it looks. Also you can change Css in the browser and have it saved in Visual Studio

在 Visual Studio 2013 中添加了浏览器链接,这允许浏览器和 Visual Studio 之间进行两种方式的通信。这意味着您可以在更改代码时刷新浏览器并立即查看它的外观。您也可以在浏览器中更改 Css 并将其保存在 Visual Studio 中