ASP.NET Web Pages (Razor) FAQ
ASP.NET Web Pages (Razor) FAQ
This article lists some frequently asked questions about ASP.NET Web Pages (Razor) and WebMatrix.
Software versions used in the tutorial
- What's the difference between ASP.NET Web Pages, ASP.NET Web Forms, and ASP.NET MVC?
- What's the difference between Web Pages and WebMatrix?
- Do I need WebMatrix in order to work with Web Pages?
- Can I use ASP.NET Web Forms controls on a Web Pages page?
- Can I deploy an ASP.NET Web Pages site without using WebMatrix?
- Do I have to use the WebSecurity helper to support logins?
- Does ASP.NET Web Pages support HTML5?
- Can I use JavaScript and jQuery with Web Pages?
- Additional Resources
For questions about errors and other issues, see the ASP.NET Web Pages (Razor) Troubleshooting Guide.
What's the difference between ASP.NET Web Pages, ASP.NET Web Forms, and ASP.NET MVC?
All three are ASP.NET technologies for creating dynamic web applications:
ASP.NET Web Pages focuses on adding dynamic (server-side) code and database access to HTML pages, and features simple and lightweight syntax.
ASP.NET Web Forms is based on a page object model and traditional window-type controls (buttons, lists, etc.). Web Forms uses an event-based model that's familiar to those who've worked with client-based (Windows forms) development.
ASP.NET MVC implements the model-view-controller pattern for ASP.NET. The emphasis is on "separation of concerns" (processing, data, and UI layers).
All three frameworks are fully supported and continue to be developed by the ASP.NET team. In general, the choice of which framework to use depends on your background and experience with ASP.NET.
ASP.NET Web Pages in particular was designed to make it easy for people who already know HTML to add server processing to their pages. It's a good choice for students, hobbyists, people in general who are new to programming. It can also be a good choice for developers who have experience with non-ASP.NET web technologies.
What's the difference between Web Pages and WebMatrix?
ASP.NET Web Pages is a programming framework for creating pages that run on the server. (See previous question.)
Microsoft WebMatrix is a tool set (an integrated development environment, or IDE) for developing many kinds of web applications. WebMatrix includes tools that are useful for web development, such as a database management tool for SQL Server Compact and MySQL databases. WebMatrix includes a local web server (IIS Express) that lets you test pages, and it lets you analyze pages for SEO and for errors. It also includes a facility for publishing sites to a hosting provider.
When you install WebMatrix, you also install ASP.NET Web Pages and other technologies like IIS Express and SQL Server Compact. Although these products are included in the WebMatrix installation process, they are also separate products.
You do not need WebMatrix in order to create ASP.NET Web Pages applications. You can use also Visual Studio, or use a text editor to create pages. (See next question.) However, the tools in WebMatrix make it easier to create and test your pages.
Conversely, you can use WebMatrix to create websites other than ASP.NET Web Pages applications. For example, you can create applications based on open-source frameworks like PHP, WordPress, DotNetNuke, Joomla!, and Drupal.
Do I need WebMatrix in order to work with Web Pages?
No. You can use Visual Studio 2013 to work with ASP.NET Web Pages sites. Visual Studio gives you many of the features of WebMatrix, plus additional ones like debugging.
If you don't want to use either WebMatrix or Visual Studio, you can install the component products individually usingMicrosoft Web Platform Installer. You need the following products:
- Microsoft .NET Framework 4.5
- ASP.NET MVC 5 (which installs the ASP.NET Web Pages framework as well)
- IIS Express (the web server)
- Microsoft SQL Server Compact 4.0 (the database)
You can use a text editor to edit .cshtml (or .vbhtml) pages.
Managing SQL Server Compact databases (.sdf files) without a tool is a bit harder. WebMatrix and Visual Studio contain tools for managing .sdf databases. You can also run SQL commands in code to perform many SQL Server management tasks.
To test .cshtml pages without using WebMatrix, you can deploy them to a live server. (See Can I deploy an ASP.NET Web Pages site without using WebMatrix?)
Running IIS Express without using WebMatrix
If you installed WebMatrix, you have IIS Express installed on your computer as a web server and you can use that to test the pages. You can run IIS Express from the command line and associate it with a specific port number. You then specify that port when you request .cshtml files in your browser.
In Windows, open a command prompt with administrator privileges and change to C:\Program Files\IIS Express. (For 64-bit systems, use the folder C:\Program Files (x86)\IIS Express.) Then enter the following command, using the actual path to your site:
iisexpress.exe /port:35896 /path:C:\BasicWebSite
You can use any port number that isn't already reserved by some other process. (Port numbers above 1024 are typically free.) For the path value, use the path of the website folder where the .cshtml files are.
After you run this command to set up IIS Express to serve your pages, you can open a browser and browse to a.cshtml file. Use a URL like the following:
http://localhost:35896/default.cshtml
For help with IIS Express command line options, enter iisexpress.exe /? at the command line.
Can I use ASP.NET Web Forms controls on a Web Pages page?
No. Web Forms controls like the CheckBox control, the validation controls, and the GridView control only work in Web Forms pages (.aspx files). These controls require the Web Forms page framework.
Can I deploy an ASP.NET Web Pages site without using WebMatrix?
Yes. You can manually copy website files to a server (typically by using FTP). If you perform a manual copy, you also have to copy the files that support SQL Server Compact (the database). For details, see the blog entry Deploying Web Pages applications without a tool.
Do I have to use the WebSecurity helper to support logins?
No. The SimpleMembership provider that is part of ASP.NET Web Pages is one option. The security providers that are part of ASP.NET (that you might be used to working with in Web Forms) are also available. For example, you can use forms authentication in ASP.NET Web Pages just as you would in Web Forms. For one example of how to use forms authentication, see the Microsoft Support article How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C#.NET. To download a simple example, see ASP.NET version of "Login & Password.
For information about how to use Windows authentication, see the blog post Using Windows authentication in ASP.NET Web Pages.
Does ASP.NET Web Pages support HTML5?
Yes. The pages you create with ASP.NET Web Pages (.cshtml or .vbhtml pages) are essentially HTML pages that also contain code that runs on the server, before the page is rendered. As long as the user's browser supports HTML5, you can use HTML5 elements in a .cshtml or .vbhtml page.
Can I use JavaScript and jQuery with Web Pages?
Absolutely. The pages you create with ASP.NET Web Pages (.cshtml or .vbhtml pages) are just HTML pages with server code in them. Therefore, anything you can do in a normal HTML page by using JavaScript or jQuery you can also do in a .cshtml or .vbhtml page.
The Starter Site template in WebMatrix contains a number of jQuery libraries. If you create a site by using that template, the Scripts folder contains a jQuery core library (jquery-1.6.2.js) and libraries for jQuery validation (jquery.validate.js, etc.).
ASP.NET Web Pages (Razor) FAQ的更多相关文章
- 如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites]
如何在ASP.NET Web站点中统一页面布局[Creating a Consistent Layout in ASP.NET Web Pages(Razor) Sites] 一.布局页面介绍[Abo ...
- Displaying Data in a Chart with ASP.NET Web Pages (Razor)
This article explains how to use a chart to display data in an ASP.NET Web Pages (Razor) website by ...
- Customizing Site-Wide Behavior for ASP.NET Web Pages (Razor) Sites
Customizing Site-Wide Behavior for ASP.NET Web Pages (Razor) Sites By Tom FitzMacken|February 17, 20 ...
- ASP.NET Web Pages (Razor) API Quick Reference
ASP.NET Web Pages (Razor) API Quick Reference By Tom FitzMacken|February 10, 2014 Print This page co ...
- ASP.NET Web Pages:Razor
ylbtech-.Net-ASP.NET Web Pages:Razor 1.返回顶部 1. ASP.NET Web Pages - 添加 Razor 代码 在本教程中,我们将使用 C# 和 Visu ...
- Web Pages razor 学习
1. Web Pages razor Web Pages 是三种 ASP.NET 编程模型中的一种,用于创建 ASP.NET 网站和 web 应用程序. 其他两种编程模型是 Web Forms 和 M ...
- ASP.NET Web Pages 的冲突版本问题
随着VS版本和.NET MVC版本.EF的版本的不断更新,虽然很多功能随着版本的提升而更完善,但对于旧版本开发的软件就有点悲催了,或许很多开发者都遇到类似的问题! 最近有一个项目是用.NET MVC3 ...
- ASP.NET Web Pages:发布网站
ylbtech-.Net-ASP.NET Web Pages:发布网站 1.返回顶部 1. ASP.NET Web Pages - 发布网站 学习如何在不使用 WebMatrix 的情况下发布 Web ...
- ASP.NET Web Pages:WebGrid 帮助器
ylbtech-.Net-ASP.NET Web Pages:WebGrid 帮助器 1.返回顶部 1. ASP.NET Web Pages - WebGrid 帮助器 WebGrid - 众多有用的 ...
随机推荐
- HttpClient超时设置
场景:最近并发较高,看到响应时间6s的时候,心里咯噔一下,我记得我设置的超时时间是5s啊. 原来读取超时时间没生效,只生效了连接超时时间. ConnectionPoolTimeoutExcepti ...
- DHCP(五)
DHCP重新登录 在经过发现,提供,选择以及应答阶段后,DHCP客户端每次重新登录网络时,就不需要再发送DHCP DISCOVER发现信息了,而是直接发送包含前一次所分配的IP地址的DHCP REQU ...
- (转)IE=EmulateIE7 标签的作用
本文转载自:http://www.cnblogs.com/0000/archive/2009/11/01/1593851.html 对于 Web 开发人员来说,文本兼容性是一个要考虑的重要问题.Win ...
- entering power save mode无法开机解决办法
标签(空格分隔): 服务器 问题描述: 服务器型号为IBM system x 3755 m3.服务器在搬动之前运行良好,换完位置之后出现按完电源键后无法进入系统,通过显示器看到entering pow ...
- thinkphp中的dump方法
感受一下,调试. 1.print_r() 2.var_dump() 3.再看看thinkphp中的dump方法 清晰多了!真实够傻的,今天才发现有这么好的调试方法.
- 概念与用法-cookie,session,auth (认证系统)
COOKIE 与 SESSION 概念 cookie不属于http协议范围,由于http协议无法保持状态,但实际情况,我们却又需要“保持状态”,因此cookie就是在这样一个场景下诞生. cookie ...
- springboot成神之——spring jdbc的使用
本文介绍spring jdbc的使用 目录结构 pom配置 properties配置 model层User类 Dao层QueryForListDao config层AppConfiguration 程 ...
- Python Twisted系列教程6:抽象地利用Twisted
作者:dave@http://krondo.com/and-then-we-took-it-higher/ 译者:杨晓伟(采用意译) 你可以从这里从头开始阅读这个系列. 打造可以复用的诗歌下载客户端 ...
- windows重启mysql命令
开始->运行->cmd 停止:net stop mysql 启动:net start mysql 前提MYSQL已经安装为windows服务
- Java微信公众平台开发(十四)【番外篇】--微信web开发者工具使用
转自:http://www.cuiyongzhi.com/post/58.html 为帮助开发者更方便.更安全地开发和调试基于微信的网页,微信推出了 web 开发者工具.它是一个桌面应用,通过模拟微信 ...