CSHTML文件可以直接运行吗? [英] Can CSHTML files run directly?

查看:95
本文介绍了CSHTML文件可以直接运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Razor V2语法启动asp.net.在Visual Studio中进行开发时,一切都很好,但是当我尝试直接从浏览器中运行.CSHTML文件时,它们将无法工作.
我想知道.CSHTML文件是旨在直接运行的,还是必须在无法直接由浏览器调用的Web应用程序的其他部分中使用?

I'm just started asp.net using Razor V2 syntax. While I'm developing in Visual Studio, everything is fine however when i try to run .CSHTML files directly from browser, they do not work.
I want to know are .CSHTML files are intended to run directly or they must be used in other segments of web applications which can not be called by browser directly?

推荐答案

是-可以直接运行cshtml页面.如果您构建ASP.NET网页(Razor)网站,则可以直接请求.cshtml页面,并且将为它们提供服务(除非文件名以下划线开头).

Yes - cshtml pages can be run directly. If you build an ASP.NET Web Pages (Razor) site, you can request .cshtml pages directly and they will be served (unless the file name starts with an underscore).

您可以通过转到文件»新建»网站来构建Razor网页站点.您可以从此处获取有关ASP.NET网页的更多信息: http://www.asp.net/网页.对于ASP.NET开发的新手来说,这是一个推荐的起点.

You can build a Razor Web Pages site by going to File » New » Web Site. You can get more information about ASP.NET Web Pages from here: http://www.asp.net/web-pages. It is the recommended starting point for people who are new to ASP.NET development.

[UPDATE] 它们也可以作为ASP.NET Core 2.0中引入的 Razor Pages网站的一部分直接运行.

[UPDATE] They can also be run directly when used as part of a Razor Pages site which was introduced in ASP.NET Core 2.0.

这篇关于CSHTML文件可以直接运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆