Wednesday, February 22, 2017

Pragramming ASP.NET web pages

1. Use WebMatrix3
Easy to use, can only access from localhost, not my laptop hostname, replaced by Visual Studio Code (hard to use)
2. Use Visual Studio 2010
Need install ASP.NET MVC 4 as this article (Programming ASP.NET Web Pages (Razor) Using Visual Studio) shows
https://docs.microsoft.com/en-us/aspnet/web-pages/overview/getting-started/program-asp-net-web-pages-in-visual-studio
Accessisble from the laptop hostname


ASP.NET Web Forms (.aspx pages)
The Web Forms framework targets developers who prefer declarative and control-based programming, such as Microsoft Windows Forms (WinForms) and WPF/XAML/Silverlight.
you can quickly build a web application without having expertise in HTML and JavaScript.

ASP.NET MVC
By dividing the application into the model (M), views (V), and controllers (C), ASP.NET MVC can make it easier to manage complexity in larger applications.

ASP.NET Web Pages (.cshtml and .vbhtml files)
ASP.NET Web Pages targets developers who want a simple web development story, along the lines of PHP. In the Web Pages model, you create HTML pages and then add server-based code to the page in order to dynamically control how that markup is rendered.
Like Web Forms, Web Pages is oriented toward rapid development.

the three frameworks are not entirely independent, and choosing one does not preclude also using another.
ASP.NET Core was released in 2016.
ASP.NET Core merges ASP.NET MVC, ASP.NET Web API, and ASP.NET Web Pages into one application framework.

@RenderPage("header.cshtml")
@RenderBody()
@RenderPage("footer.cshtml")
With ASP.NET, files with a name that starts with an underscore cannot be browsed from the web:
_header.cshtml, _footer.cshtml, _Layout.cshtml
With ASP.NET, the common way to hide sensitive information (database passwords, email passwords, etc.) is to keep the information in a separate file named "_AppStart"
To specify the virtual root in programming code, use the ~ operator.
The Server.MapPath method converts a virtual path (/default.cshtml) to a physical path that the server can understand
The Href method converts a path used in the code to a path that the browser can understand

No comments:

Post a Comment