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 - 众多有用的 ...
随机推荐
- 基于SQL调用Com组件来发送邮件
这个需求是公司有个文控中心,如果有用增删改了文件信息希望可以发邮件通知到有权限的人.当然方式很多. 这里是用数据库作业来完成 JOB+Com,这里用的com组件是Jmail 当然你需要把com组件放到 ...
- mysql不能使用localhost登录
解决mysql不能使用localhost or 127.0.0.1登录 参考:http://soft.chinabyte.com/database/409/12669909.shtml 因为root账 ...
- FPGA中的“门”
逻辑门 在ASIC的世界里,衡量器件容量的常用标准是等效门.这是因为不同的厂商在单元库里提供了不同的功能模块,而每个功能模块的实现都要求不同数量的晶体管.这样在两个器件之间比较容量和复杂度就很困难. ...
- linux文件系统命令和分区 挂载
文件系统命令df [选项][挂载点]选项:-a 显示所有的文件系统信息,包括特殊文件,如/proc,/sysfs-h 使用习惯单位显示容量,如KB,MB或GB等-T 显示文件系统类型-m 以MB为单位 ...
- 【转】Jmeter测试结果分析
Jmeter测试结果分析这一篇,我打算分成上下两部分.上篇,主要讲述如何使用jmeter中Assertion对结果进行简单的分类:下篇,主要讲述的是当我们拿到测试结果后,我们应该如何去看待这些测试结果 ...
- 分表分库之二:唯一ID的生成方法
一.为什么要全局唯一? 我们在对数据库集群作扩容时,为了保证负载的平衡,需要在不同的Shard之间进行数据的移动, 如果主键不唯一,我们就没办法这样随意的移动数据.起初,我们考虑采用组合主键来解决这个 ...
- 关于Unity发布iOS平台代码混淆问题
之前在越狱手机里找到<永恒战士3>的程序发现是用Unity做的,拷出资源出来看的时候发现里面有游戏程序集,立马抽出来反编译了一下,发现里面的代码只有方法签名,没有方法体,还以为用什么高端混 ...
- 命令提示符(cmd)中的tracert命令详解(小技巧)
tracert也被称为Windows路由跟踪实用程序,在命令提示符(cmd)中使用tracert命令可以用于确定IP数据包访问目标时所选择的路径.本文主要探讨了tracert命令的各个功能. 百度经验 ...
- Py修行路 python基础 (十六)面向对象编程的 继承 多态与多态性 封装
一.继承顺序: 多继承情况下,有两种方式:深度优先和广度优先 1.py3/py2 新式类的继承:在查找属性时遵循:广度优先 继承顺序是多条分支,按照从左往右的顺序,进行一步一步查找,一个分支走完会走另 ...
- java - 只输出中文,(不包含标点)
String a ="12dss显示,‘:()中文只"; StringBuffer b = new StringBuffer(); for(int i = 0;i<a.len ...