About Coldfusion - Sciter Ui, Application Architecture

Vấn đề với các ứng dụng website là chúng được tiếp xúc công khai với sản phẩm tỷ người tiêu dùng internet, nhiều người trong số họ sẽ mong phá vỡ các biện pháp bảo mật của nó – vì bất cứ lý vị gì.

Bạn đang xem: About coldfusion

Trong gần như ngày đầu của Internet, 1 trong những những cách thức tấn công thông dụng nhất là đấm đá bạo lực cơ bản, 1-1 giản. Bots thường thực hiện các cuộc tiến công này - hoặc phần nhiều người có tương đối nhiều thời gian làm việc - những người dân đã thử phối kết hợp các tên người tiêu dùng và mật khẩu cho đến khi bọn họ tìm thấy một chiếc sẽ cấp quyền truy cập vào vận dụng mục tiêu.

Các cuộc tiến công vũ lực không hề là hiểm họa nữa, nhờ vào vào chế độ mật khẩu, chu kỳ đăng nhập tiêu giảm và hình hình ảnh xác thực. Cơ mà tội phạm mạng thích tò mò những cách khai thác mới và sử dụng chúng để tiến hành các kiểu tấn công mới. Từ thời điểm cách đó rất lâu, họ đang phát hiển thị rằng những trường văn bạn dạng trên những ứng dụng hoặc trang web có thể bị khai thác bằng phương pháp nhập – hoặc chèn – văn bản bất ngờ vào chúng sẽ buộc ứng dụng thực hiện một bài toán mà nó không được phép làm. Bằng cách đó, phần đông cuộc tấn công được call là tiêm chích vẫn vào hiện nay trường.

Các cuộc tấn công tiêm có thể được sử dụng không chỉ là để đăng nhập vào một trong những ứng dụng mà lại không cần phải biết tên người tiêu dùng và mật khẩu, ngoại giả để tiết lộ thông tin riêng rẽ tư, kín đáo hoặc nhạy bén hoặc thậm chí là để chiếm đoạt toàn bộ máy chủ. Đó là lý do tại sao các cuộc tiến công này không chỉ là mối doạ dọa so với các vận dụng web nhưng mà còn đối với người dùng có dữ liệu nằm trên các ứng dụng đó cùng trong trường hòa hợp xấu nhất là các ứng dụng và thương mại dịch vụ được kết nối khác.


*

1) Chèn mã

Chèn mã là một trong những kiểu tiến công tiêm mã thịnh hành nhất. Nếu số đông kẻ tấn công biết ngôn từ lập trình, khuôn khổ, cơ sở tài liệu hoặc hệ điều hành được vận dụng web sử dụng, chúng rất có thể chèn mã trải qua các ngôi trường nhập văn phiên bản để buộc sever web làm hầu như gì chúng muốn.

Các kiểu tấn công tiêm này rất có thể xảy ra trên những ứng dụng thiếu thốn xác thực tài liệu đầu vào. Để chống chặn những cuộc tiến công này, ứng dụng cần tiêu giảm càng những càng tốt người dùng đầu vào được phép truy vấn cập.

Các lỗ hổng chèn mã có thể dễ dàng tìm kiếm thấy, chỉ bằng phương pháp kiểm tra đầu vào văn bạn dạng của một vận dụng web với các loại câu chữ khác nhau. Lúc được tìm thấy, các lỗ hổng này rất cạnh tranh khai thác. Mà lại khi kẻ tấn công khai thác trong những lỗ hổng này, ảnh hưởng tác động có thể bao gồm mất tính bảo mật, tính toàn vẹn, tính khả dụng hoặc công dụng của ứng dụng.


*

2) Chèn SQL

Theo kiểu giống như như vấn đề chèn mã, cuộc tiến công này vẫn chèn một tập lệnh SQL – ngữ điệu được số đông các cơ sở dữ liệu sử dụng để thực hiện các làm việc truy vấn– trong trường nhập văn bản. Tập lệnh được gửi đến ứng dụng, ứng dụng này tiến hành nó trực tiếp bên trên cơ sở dữ liệu của nó. Vị đó, kẻ tấn công có thể đi qua screen đăng nhập hoặc làm rất nhiều việc gian nguy hơn, như đọc tài liệu nhạy cảm trực tiếp từ cửa hàng dữ liệu, sửa đổi hoặc tiêu diệt dữ liệu cơ sở tài liệu hoặc tiến hành các thao tác quản trị trên cơ sở dữ liệu.

Các vận dụng PHP với ASP dễ bị tấn công SQL injection do những giao diện tính năng cũ của nó. Những ứng dụng J2EE cùng ASP.Net hay được bảo vệ tốt rộng trước các cuộc tấn công này. Lúc 1 lỗ hổng SQL injection được tìm thấy –và chúng có thể dễ dàng được search thấy – nút độ của những cuộc tấn công tiềm ẩn vẫn chỉ bị giới hạn bởi khả năng và trí tưởng tượng của kẻ tấn công. Vị đó, tác động ảnh hưởng của một cuộc tấn công SQL injection chắc chắn rằng là vô cùng cao.


*

3) Chèn lệnh

Các cuộc tấn công này cũng có thể xảy ra, chủ yếu là vì không đủ chính xác đầu vào. Bọn chúng khác với những cuộc tiến công chèn mã ở trong phần kẻ tiến công chèn những lệnh khối hệ thống thay vì các đoạn mã hoặc tập lệnh lập trình. Vày đó, tin tặc không cần biết ngôn ngữ lập trình nhưng mà ứng dụng dựa trên hoặc ngữ điệu được cơ sở dữ liệu sử dụng. Tuy thế họ nên biết hệ quản lý điều hành được thực hiện bởi máy chủ lưu trữ.

Các lệnh khối hệ thống đã chèn được tiến hành bởi hệ điều hành máy chủ với các độc quyền của ứng dụng, gồm thể cho phép hiển thị nội dung của những tệp tùy ý nằm trên thiết bị chủ, nhằm hiển thị cấu tạo thư mục của máy chủ, để biến hóa mật khẩu tín đồ dùng, và những thứ khác.


*

4) Tập lệnh trên các trang

Bất cứ lúc nào một ứng dụng chèn nguồn vào từ người dùng bên phía trong đầu ra mà nó tạo thành ra, nhưng mà không đảm bảo hoặc mã hóa nó, nó đã tạo cơ hội cho kẻ tiến công gửi mã độc cho một người dùng cuối khác. Các cuộc tiến công Cross-Site Scripting (XSS) tận dụng tối đa những cơ hội này để đưa các tập lệnh ô nhiễm vào các trang web đáng tin cậy, hầu như tập lệnh này sau cuối được gửi mang lại những người dùng khác của ứng dụng, những người này sẽ biến chuyển nạn nhân của kẻ tấn công.

Trình lưu ý của nạn nhân sẽ triển khai tập lệnh ô nhiễm và độc hại mà lần chần rằng nó không đáng tin cậy. Do đó, trình coi ngó sẽ có thể chấp nhận được nó truy cập mã thông tin phiên, cookie hoặc tin tức nhạy cảm được trình chuyên chú lưu trữ. Trường hợp được lập trình đúng cách, những tập lệnh thậm chí hoàn toàn có thể viết lại nội dung của một tệp HTML.

5) Chèn XPath

Kiểu tiến công này có thể xảy ra khi vận dụng web sử dụng tin tức do người dùng cung cấp để sản xuất truy vấn XPath cho dữ liệu XML. Cách thức hoạt động của các cuộc tấn công này tương tự như như SQL injection: hầu hết kẻ tấn công gửi thông tin không đúng format đến vận dụng để tìm ra cách dữ liệu XML được kết cấu và tiếp đến chúng tiến công lại để truy cập vào dữ liệu đó.

XPath là 1 ngôn ngữ tiêu chuẩn, hệt như SQL, bạn có thể chỉ định những thuộc tính bạn có nhu cầu tìm. Để thực hiện một truy hỏi vấn trên tài liệu XML, những ứng dụng website sử dụng nguồn vào của người dùng làm đặt một mẫu mà tài liệu phải khớp. Bằng cách gửi nguồn vào không đúng định dạng, mẫu có thể trở thành một vận động mà kẻ tấn công muốn vận dụng cho dữ liệu.

Không hệt như những gì xảy ra với SQL, trong XPath, không có phiên bạn dạng nào khác nhau. Điều này tức là việc tiêm XPath rất có thể được triển khai trên bất kỳ ứng dụng web nào sử dụng tài liệu XML, bất kể việc thực thi là gì. Điều đó cũng tức là cuộc tấn công rất có thể được tự động hóa; vày đó, không giống như SQL injection, nó có chức năng bị kích hoạt so với một số kim chỉ nam tùy ý.


*

6) Chèn lệnh thư

Phương thức tấn công này rất có thể được sử dụng để khai quật các máy chủ email và vận dụng xây dựng các câu lệnh IMAP hoặc SMTP với nguồn vào của người dùng được tuyệt đối không đúng cách. Đôi khi, những máy nhà IMAP cùng SMTP không tồn tại khả năng bảo đảm an toàn mạnh mẽ trước những cuộc tấn công, như trường thích hợp của hầu như các máy chủ web và vì chưng đó có thể dễ bị khai quật hơn. Vào trải qua máy nhà thư, gần như kẻ tấn công hoàn toàn có thể trốn tránh các hạn chế như hình hình ảnh xác thực, một số trong những yêu cầu hạn chế, v.v.

Để khai thác một sever SMTP, phần đa kẻ tiến công cần một tài khoản e-mail hợp lệ để nhắn tin nhắn với những lệnh được chuyển vào. Nếu máy chủ dễ bị tấn công, nó sẽ bình luận yêu cầu của rất nhiều kẻ tấn công, chẳng hạn như được cho phép chúng ghi đè những hạn chế của dòng sản phẩm chủ cùng sử dụng những dịch vụ của nó để giữ hộ spam.

Việc đưa IMAP có thể được tiến hành chủ yếu trên những ứng dụng webmail, khai thác tác dụng đọc tin nhắn. Trong số những trường phù hợp này, cuộc tấn công hoàn toàn có thể được thực hiện bằng phương pháp chỉ đề nghị nhập, vào thanh địa chỉ cửa hàng của trình duyệt web, một URL với các lệnh được đưa vào.

7) CRLF

Việc chèn cam kết tự xuống loại và ký tự mối cung cấp cấp tài liệu dòng – tổ hợp được gọi là CRLF– trong số trường nhập biểu mẫu mã web thay mặt cho một phương thức tấn công được call là tiêm CRLF. Những ký trường đoản cú ẩn này đã cho thấy phần cuối của một dòng hoặc phần cuối của một lệnh trong không ít giao thức mạng internet truyền thống, ví dụ như HTTP, MIME hoặc NNTP.

Ví dụ: việc chèn CRLF vào một trong những yêu mong HTTP, theo sau là một số mã HTML độc nhất định, có thể gửi những trang web thiết lập cấu hình đến khách truy vấn của một trang web.

Cuộc tiến công này rất có thể được thực hiện trên những ứng dụng web dễ dàng bị tiến công không vận dụng bộ lọc thích hợp cho nguồn vào của tín đồ dùng. Lỗ hổng này xuất hiện thêm cánh cửa cho các loại tiến công chèn nghiền khác, ví dụ như XSS với chèn mã, cùng cũng hoàn toàn có thể bắt nguồn từ các việc một trang web bị chỉ chiếm quyền điều khiển.

8) Chèn tiêu đề đồ vật chủ

Trong những máy chủ lưu trữ nhiều website hoặc ứng dụng web, tiêu đề máy chủ lưu trữ trở nên quan trọng để xác định trang web hoặc áp dụng web thường xuyên trú nào –trong số này được gọi là máy chủ ảo– sẽ cách xử trí một yêu cầu đến. Quý hiếm của title cho sever biết sever ảo nào để gửi yêu thương cầu. Khi máy chủ nhận được tiêu đề sever lưu trữ chưa hợp lệ, nó thường chuyển nó đến sever ảo thứ nhất trong danh sách. Điều này tạo thành một lỗ hổng mà đều kẻ tấn công hoàn toàn có thể sử dụng để gửi tiêu đề sever tùy ý đến máy chủ ảo thứ nhất trong một lắp thêm chủ.

Thao tác với tiêu đề sever thường tương quan đến các ứng dụng PHP, mặc dù nó cũng có thể được triển khai với các công nghệ phát triển website khác. Các cuộc tấn công tiêu đề đồ vật chủ chuyển động như một công cụ hỗ trợ cho các loại tấn công khác, chẳng hạn như đầu độc bộ đệm web. Kết quả của nó gồm thể bao hàm việc những kẻ tiến công thực hiện các vận động nhạy cảm, ví như đặt lại mật khẩu.

Ngăn chặn các cuộc tiến công

Như chúng ta đã thấy trong nội dung bài viết này, tất cả các cuộc tấn công tiêm truyền đều hướng tới các sever và vận dụng có quyền truy cập mở cho ngẫu nhiên người cần sử dụng internet nào. Nhiệm vụ ngăn chặn các cuộc tấn công này được phân bổ giữa những nhà phát triển ứng dụng với quản trị viên lắp thêm chủ.

Các nhà phát triển ứng dụng cần biết các rủi ro khủng hoảng liên quan đến việc xác nhận không chính xác thông tin đầu vào của người tiêu dùng và mày mò các phương thức hay nhất để gia công sạch thông tin đầu vào của người tiêu dùng với mục tiêu phòng đề phòng rủi ro. Quản lí trị viên sever cần kiểm tra hệ thống của họ thời hạn để vạc hiện các lỗ hổng với sửa chúng càng sớm càng tốt. Có nhiều lựa chọn để thực hiện các cuộc soát sổ này, theo yêu cầu hoặc từ bỏ động.


WAPPLES, đảm bảo an toàn Ứng dụng Web giỏi nhất

Penta Security’s WAPPLES là 1 tường lửa áp dụng web phát hiện nay một cách hợp lí các tập lệnh ô nhiễm từ lưu giữ lượng ứng dụng web. Luật phát hiện dựa trên quy tắc của nó chất nhận được đạt tác dụng tối đa nhưng mà không ảnh hưởng đến hiệu suất ứng dụng.

Được quản lý bởi phương pháp phát hiện dựa trên quy tắc đã làm được cấp bằng bản quyền sáng tạo COCEPTM, WAPPLES hiện tại sở hữu một đội gồm 33 quy tắc có thể được điều khiển để tạo nên các chính sách bảo mật tùy chỉnh mạnh mẽ.

Các luật lệ của WAPPLES được khẳng định một cách tinh vi bằng phương pháp phân tích logic những kiểu tấn công của hàng triệu cuộc tấn công, tạo nên nó có tác dụng ngay cả khi chống lại những cuộc tấn công zero-day. Cập nhật định kỳ với tự chẩn đoán giữ cho nó sinh sống trạng thái giỏi nhất, sẵn sàng chuẩn bị cho các tai hại mới nhất.

Được máy bộ thăng bằng tải, WAPPLES bao gồm sẵn ở cả dạng phần cứng và phần mềm, bảo đảm các máy chủ tại địa điểm và dựa trên đám mây.

Với thị phần số 1 ở quanh vùng Châu Á tỉnh thái bình Dương, WAPPLES là giải pháp tốt tuyệt nhất để phòng lại toàn bộ các loại tiến công SQL injection.


itmapasia.com | itmapasia.com

The problem with website applications is that they are openly exposed khổng lồ billions of internet users, many of which will want lớn break its security measures –for whatever the reasons.

In the early days of the Internet, one of the most common attack methods was basic, simplebrute force. Bots usually performed these attacks –or persons with plenty of time off– who tried zillions of combinations of usernames và passwords until they found one that would grant access khổng lồ the target application.

Brute force attacks are no longer a threat, thanks to lớn password policies, limited login attempts, & captchas. But cybercriminals love khổng lồ discover new exploits và to use them khổng lồ perform new types of attacks. Long ago, they discovered that text fields on applications or website pages could be exploited by entering –or injecting– unexpected text into them that would force the application to vì chưng something it was not supposed to do. In that way, the so-called injection attacks entered the scene.

Injection attacks can be used not only to log in lớn an application without knowing username and password, but also to lớn expose private, confidential, or sensitive information, or even lớn hijack an entire server. That is why these attacks are not only athreat lớn web applications, but also khổng lồ the users whose data resides on those applications, and in the worst cases, to other connected applications và services.

1)Code injection

Code injection is one of the most common types of injection attacks. If attackers know the programming language, the framework, the database or the operating system used by a web application, they can inject code via text input đầu vào fields lớn force the webserver to vày what they want.

These types of injection attacks are possible on applications that lack input đầu vào data validation. To lớn prevent these attacks, the application needs to lớn restrict as much as it can the đầu vào users are allowed to lớn enter.

The code injection vulnerabilities can be easy khổng lồ find, just by testing the text input đầu vào of a website application with different types of content. When found, the vulnerabilities are moderately hard to exploit. But when an attacker manages lớn exploit one of these vulnerabilities, the impact could include loss of confidentiality, integrity, availability, or application functionality.

2)SQL injection

In a similar fashion lớn code injection, this attack inserts an SQL script –the language used by most databases to perform query operations– in a text input field. The script is sent to lớn the application, which executes it directly on its database. As a result, the attacker could pass through a login screen or vì more dangerous things, like read sensitive data directly from the database, modify or destroy database data, or execute admin operations on the database.

PHP and ASP applications are prone to
SQL injection attacksdue lớn its older functional interfaces. J2EE and ASP.Net apps are usually more protected against these attacks. When an SQL injection vulnerability is found –and they could be easily found–the magnitude of the potential attacks will only be limited by the attacker’s skill và imagination. Thus, the impact of an SQL injection attack is undoubtedly high.

3)Command injection

These attacks are also possible, mainly due lớn insufficient đầu vào validation. They differ from code injection attacks in that the attacker inserts system commands instead of pieces of programming code or scripts. Therefore, tin tặc doesn’t need khổng lồ know the programming language in which the application is based or the language used by the database. But they need khổng lồ know the operating system used by the hosting server.

The inserted system commands are executed by the host operating system with theprivileges of the application, which could allow for exposing the nội dung of arbitrary files residing on the server, for showing the directory structure of a server, for changing user passwords, among other things.

4)Cross-site scripting

Whenever an application inserts input from a user within the đầu ra it generates, without validating or encoding it, it gives the opportunity lớn an attacker to lớn send malicious code to lớn a different end-user. Cross-Site Scripting (XSS) attacks take these opportunities khổng lồ inject malicious scripts into trusted websites, which is ultimately sent to other users of the application, which become the attacker’s victims.

The victims’ browser will execute the malicious script without knowing it should not be trusted. Therefore, the browser will let it access session tokens, cookies, or sensitive information stored by the browser. If properly programmed, the scripts could even rewrite the contents of an HTML file.

5)XPath injection

This type of attack is possible when a web application uses information provided by a user khổng lồ build an XPath query for XML data. The way these attack works is similar to
SQL injection: attackers send malformed information to lớn the application in order to lớn find out how the XML data is structured, & then they attack again to access that data.

XPath is a standard language with which, like SQL, you can specify the attributes you want khổng lồ find. To perform a query on XML data, website applications use user input to mix a pattern the data should match. By sending malformed input, the pattern can turn into an operation that the attacker wants to lớn apply khổng lồ the data.

Unlike what happens with SQL, in XPath, there are no different versions. This means that XPath injection can be done on any website application that uses XML data, regardless of the implementation. That also means that the attack can be automated; therefore, unlike SQL injection, it has the potential lớn be fired against an arbitrary number of objectives.

6)Mail command injection

This attack method can be used to lớn exploit e-mail servers and applications that build IMAP or SMTP statements with improperly validated user input. Occasionally, IMAP & SMTP servers don’t have strong protection against attacks, as it would be the case with most website servers, and therefore could be more exploitable. Entering through a mail server, attackers could evade restrictions such as captchas, a limited number of requests, etc.

To exploit an SMTP server, attackers need a valid email account to send messages with injected commands. If the server is vulnerable, it will respond khổng lồ the attackers’ requests, allowing them, for example, khổng lồ override vps restrictions & use its services to lớn send spam.

IMAP injection could be done mainly on webmail applications, exploiting the message reading functionality. In these cases, the attack can be performed by simply entering, in the address bar of a website browser, a URL with the injected commands.

7)CRLF injection

The insertion of carriage return and line feed characters –combination known as CRLF– in website form đầu vào fields represents an attack method called CRLF injection. These invisible characters indicate the over of a line or the over of a command in many traditional mạng internet protocols, such as HTTP, MIME, or NNTP.

For example, the insertion of a CRLF into an HTTP request, followed by some certain HTML code, could send custom website pages khổng lồ the visitors of a website.

This attack can be performed on vulnerable web applications that don’t apply the proper filtering to lớn the user input. This vulnerability opens the door to lớn other types of injection attacks, such as XSS và code injection, và could also derive in a trang web being hijacked.

8)Host Header injection

In servers that host many websites or website applications, the host header becomes necessary khổng lồ determine which of the resident websites or website applications –each of them known as a virtual host– should process an incoming request. The value of the header tells the vps to which of the virtual hosts to lớn dispatch a request. When the hệ thống receives an invalid host header, it usually passes it to the first virtual host in the list. This constitutes a vulnerability that attackers can use khổng lồ send arbitrary host headers lớn the first virtual host in a server.

Manipulation of the host header is commonly related lớn PHP applications, although it can also be done with other website development technologies. Host header attacks work as enablers for other types of attacks, such as web-cache poisoning. Its consequences could include the execution of sensitive operations by the attackers, for example, password resets.

Preventing injection attacks

As we saw in this article, all injection attacks are directed towards servers and applications with xuất hiện access khổng lồ any internet user. The responsibility khổng lồ prevent these attacks is distributed among application developers and server administrators.

Application developers need to know the risks involved in the incorrect validation of user input và ungdungfb.com best practices khổng lồ sanitize user input đầu vào with risk prevention purposes. Vps administrators need to audit their systems periodically todetect vulnerabilitiesand correct them as soon as possible. There are many options lớn perform these audits, either on-demand or automatically.

WAPPLES, theBest website Application Defence

Penta Security’sWAPPLESis a website application firewall that logically detects malicious scripts from web application traffic. Its rule-based detection engine allows for maximum efficiency without compromising application performance.

Run by its patented rule-based detection engine COCEPTM, WAPPLES currently possesses a pool of 33 rules that can be fine-tuned khổng lồ create robust custom security policies.

WAPPLES’ rules are sophisticatedly defined by logically analyzing the attack patterns of millions of attacks, making it effective even against zero-day attacks. Periodic updates and self-diagnostics keep it at its best state ready for the newest threats.

Equipped with a load balancer, WAPPLES is available in both hardware and software forms, protecting on-premises and cloud-based servers.

With the No.1 market tóm tắt in the Asia Pacific region, WAPPLES is the best solution against all types of SQL injection attacks.

Watch thisexciting videoto ungdungfb.com more aboutWAPPLES’amazing features and benefits.

Read more to lớn ungdungfb.com about the technicalreasons why you need a WAFand
WAPPLES, a rule-based customizable WAF,here today.

This isn"t the latest version of this article. For the current release, see the .NET 8 version of this article.


Important

This information relates to a pre-release sản phẩm that may be substantially modified before it"s commercially released. ungdungfb.com makes no warranties, express or implied, with respect to lớn the information provided here.

For the current release, see the .NET 8 version of this article.


This is the first tutorial of a series that teaches the basics of building an ASP.NET bộ vi xử lý core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers và views, see Introduction to lớn Razor Pages. For a video introduction, see Entity Framework vi xử lý core for Beginners.

If you"re new khổng lồ ASP.NET bộ vi xử lý core development & are unsure of which ASP.NET vi xử lý core web UI solution will best fit your needs, see Choose an ASP.NET chip core UI.

At the kết thúc of this tutorial, you"ll have a Razor Pages web app that manages a database of movies.

*

Prerequisites


The Visual Studio Code instructions use the .NET CLI for ASP.NET core development functions such as project creation. You can follow these instructions on mac
OS, Linux, or Windows & with any code editor. Minor changes may be required if you use something other than Visual Studio Code.

Visual Studio 2022 for Mac (latest version)


Important

ungdungfb.com has announced the retirement of Visual Studio for Mac. Visual Studio for Mac will no longer be supported starting August 31, 2024. Alternatives include:

Visual Studio IDE running on Windows in a VM on Mac.

For more information, see Visual Studio for Mac retirement announcement.


Create a Razor Pages web app


Start Visual Studio and select New project.

In the Create a new project dialog, select ASP.NET core Web ứng dụng (Razor Pages) > Next.

In the Configure your new project dialog, enter Razor
Pages
Movie for Project name. It"s important to name the project Razor
Pages
Movie
, including matching the capitalization, so the namespaces will match when you copy và paste example code.

Select Next.

In the Additional information dialog:

Select .NET 8.0 (Long Term Support).Verify: Do not use top-level statements is unchecked.

Select Create.

*

The following starter project is created:

*

For alternative approaches lớn create the project, see Create a new project in Visual Studio.

The tutorial assumes familiarity with VS Code. For more information, see Getting started with VS Code.

Change to the directory (cd) that will contain the project.

Run the following commands:

dotnet new webapp -o Razor
Pages
Moviecode -r Razor
Pages
Movie
The dotnet new command creates a new Razor Pages project in the Razor
Pages
Movie
folder.

The code command opens the Razor
Pages
Movie
thư mục in the current instance of Visual Studio Code.

Visual Studio Code might display a dialog box that asks: Do you trust the authors of the files in this folder?

If you trust all files in the parent folder, select Trust the authors of all files in the parent folder.Select Yes, I trust the authors since the project thư mục has files generated by .NET.When Visual Studio Code requests that you add assets lớn build và debug the project, select Yes. If Visual Studio Code doesn"t offer to showroom build & debug assets, select View > Command Palette & type ".NET" into the search box. From the menu of commands, select the .NET: Generate Assets for Build and Debug command.

Visual Studio Code adds a .vscode folder with generated launch.json and tasks.json files.

In Visual Studio for Mac 2022, select File > New Project....

In the Choose a template for your new project dialog:

Select Web & Console > App > Web Application.Select Continue.

In the Configure your new website Application dialog:

Verify: Target framework is set to .NET 8.0 (or later).Verify: Authentication is set khổng lồ No Authentication.Verify: Do not use top-level statements is unchecked.Select Continue.

In the Configure your new web Application dialog:

Enter Razor
Pages
Movie for Project name. It"s important to lớn name the project Razor
Pages
Movie
, including matching the capitalization, so the namespaces will match when you copy và paste example code.Select Create.

Select Razor
Pages
Movie
in Solution Explorer, and then press Ctrl+F5 khổng lồ run the phầm mềm without the debugger.

Visual Studio displays the following dialog when a project is not yet configured lớn use SSL:

*

Select Yes if you trust the IIS Express SSL certificate.

The following dialog is displayed:

*

Select Yes if you agree khổng lồ trust the development certificate.

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

Visual Studio:

Launches the mặc định browser at https://localhost:

, which displays the apps UI. is the random port that is assigned when the ứng dụng was created.Close the browser window.

Trust the HTTPS development certificate by running the following command:

dotnet dev-certs https --trust
The preceding command doesn"t work on Linux. See your Linux distribution"s documentation for trusting a certificate.

The preceding command displays the following dialog, provided the certificate was not previously trusted:

*

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

In Visual Studio Code, press Ctrl+F5 (Windows) or ⌘+F5 (mac
OS) to run the phầm mềm without debugging.

At the Select debugger prompt, select .NET 5+ and .NET Core.

*

The default browser launched with the following URL: https://localhost: where is the randomly generated port number.

Close the browser window.

In Visual Studio Code, from the Run menu, select Stop Debugging or press Shift+F5 khổng lồ stop the app.

Select Debug > Start Debugging to lớn launch the app.

Visual Studio for Mac launches a browser & navigates lớn https://localhost:, where is the port number randomly assigned at project creation and is set in Properties/launch
Settings.json.

Close the browser window.


Examine the project files

The following sections contain an overview of the main project folders và files that you"ll work with in later tutorials.

Pages folder

Contains Razor pages and supporting files. Each Razor page is a pair of files:

A .cshtml tệp tin that has HTML markup with C# code using Razor syntax.A .cshtml.cs tệp tin that has C# code that handles page events.

wwwroot folder

Contains static assets, like HTML files, Java
Script files, và CSS files. For more information, see Static files in ASP.NET Core.

appsettings.json

Contains configuration data, lượt thích connection strings. For more information, see Configuration in ASP.NET Core.

Xem thêm: Sorry, Something Went Wrong Error On Facebook App On Iphone Fix

Program.cs

Contains the following code:

var builder = Web
Application.Create
Builder(args);// add services to lớn the container.builder.Services.Add
Razor
Pages();var ứng dụng = builder.Build();// Configure the HTTP request pipeline.if (!app.Environment.Is
Development()) app.Use
Exception
Handler("/Error"); // The mặc định HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. App.Use
Hsts();app.Use
Https
Redirection();app.Use
Static
Files();app.Use
Routing();app.Use
Authorization();app.Map
Razor
Pages();app.Run();The following lines of code in this tệp tin create a Web
Application
Builder with preconfigured defaults, showroom Razor Pages support to the Dependency Injection (DI) container, and builds the app:

var builder = Web
Application.Create
Builder(args);// showroom services khổng lồ the container.builder.Services.Add
Razor
Pages();var app = builder.Build();The developer exception page is enabled by default and provides helpful information on exceptions. Production apps should not be run in development mode because the developer exception page can leak sensitive information.

The following code sets the exception endpoint to lớn /Error & enables HTTP Strict Transport Security Protocol (HSTS) when the app is not running in development mode:

// Configure the HTTP request pipeline.if (!app.Environment.Is
Development()) app.Use
Exception
Handler("/Error"); // The mặc định HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. App.Use
Hsts();For example, the preceding code runs when the phầm mềm is in production or kiểm tra mode. For more information, see Use multiple environments in ASP.NET Core.

The following code enables various Middleware:

app.Use
Https
Redirection(); : Redirects HTTP requests to HTTPS.app.Map
Razor
Pages();: Configures endpoint routing for Razor Pages.app.Use
Authorization(); : Authorizes a user to lớn access secure resources. This app doesn"t use authorization, therefore this line could be removed.app.Run(); : Runs the app.

Troubleshooting with the completed sample

If you run into a problem you can"t resolve, compare your code khổng lồ the completed project. View or tải về completed project (how to download).

Next steps


This is the first tutorial of a series that teaches the basics of building an ASP.NET vi xử lý core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers và views, see Introduction to lớn Razor Pages. For a đoạn phim introduction, see Entity Framework vi xử lý core for Beginners.

If you"re new khổng lồ ASP.NET core development & are unsure of which ASP.NET chip core web UI solution will best fit your needs, see Choose an ASP.NET bộ vi xử lý core UI.

At the over of this tutorial, you"ll have a Razor Pages web phầm mềm that manages a database of movies.

*

Prerequisites


The Visual Studio Code instructions use the .NET CLI for ASP.NET vi xử lý core development functions such as project creation. You can follow these instructions on mac
OS, Linux, or Windows và with any code editor. Minor changes may be required if you use something other than Visual Studio Code.

Visual Studio 2022 for Mac (latest version)


Important

ungdungfb.com has announced the retirement of Visual Studio for Mac. Visual Studio for Mac will no longer be supported starting August 31, 2024. Alternatives include:

Visual Studio IDE running on Windows in a VM on Mac.

For more information, see Visual Studio for Mac retirement announcement.


Start Visual Studio and select Create a new project.

In the Create a new project dialog, select ASP.NET chip core Web App > Next.

In the Configure your new project dialog, enter Razor
Pages
Movie for Project name. It"s important lớn name the project Razor
Pages
Movie
, including matching the capitalization, so the namespaces will match when you copy & paste example code.

Select Next.

In the Additional information dialog:

Select .NET 7.0 (Standard Term Support).Verify: Do not use top-level statements is unchecked.

Select Create.

*

The following starter project is created:

*

For alternative approaches khổng lồ create the project, see Create a new project in Visual Studio.

The tutorial assumes familiarity with VS Code. For more information, see Getting started with VS Code.

Change lớn the directory (cd) that will contain the project.

Run the following commands:

dotnet new webapp -o Razor
Pages
Moviecode -r Razor
Pages
Movie
The dotnet new command creates a new Razor Pages project in the Razor
Pages
Movie
folder.

The code command opens the Razor
Pages
Movie
project thư mục in the current instance of Visual Studio Code.

Visual Studio Code might display a dialog box that asks: Do you trust the authors of the files in this folder?

If you trust all files in the parent folder, select Trust the authors of all files in the parent folder.Select Yes, I trust the authors since the project thư mục has files generated by .NET.When Visual Studio Code requests that you địa chỉ assets lớn build và debug the project, select Yes. If Visual Studio Code doesn"t offer to địa chỉ cửa hàng build & debug assets, select View > Command Palette and type ".NET" into the tìm kiếm box. From the list of commands, select the .NET: Generate Assets for Build & Debug command.

Visual Studio Code adds a .vscode folder with generated launch.json và tasks.json files.

In Visual Studio for Mac 2022, select File > New Project....

In the Choose a template for your new project dialog:

Select Web và Console > App > Web Application.Select Continue.

In the Configure your new website Application dialog:

Verify: Target framework is set to lớn .NET 7.0 (or later).Verify: Authentication is set to lớn No Authentication.Verify: Do not use top-level statements is unchecked.Select Continue.

In the Configure your new web Application dialog:

Enter Razor
Pages
Movie for Project name. It"s important khổng lồ name the project Razor
Pages
Movie
, including matching the capitalization, so the namespaces will match when you copy and paste example code.Select Create.

Select Razor
Pages
Movie
in Solution Explorer, and then press Ctrl+F5 khổng lồ run the tiện ích without the debugger.

Visual Studio displays the following dialog when a project is not yet configured khổng lồ use SSL:

*

Select Yes if you trust the IIS Express SSL certificate.

The following dialog is displayed:

*

Select Yes if you agree khổng lồ trust the development certificate.

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

Visual Studio:

Launches the default browser at https://localhost:

, which displays the apps UI. is the random port that is assigned when the app was created.Close the browser window.

Trust the HTTPS development certificate by running the following command:

dotnet dev-certs https --trust
The preceding command doesn"t work on Linux. See your Linux distribution"s documentation for trusting a certificate.

The preceding command displays the following dialog, provided the certificate was not previously trusted:

*

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

In Visual Studio Code, press Ctrl+F5 (Windows) or ⌘+F5 (mac
OS) lớn run the app without debugging.

At the Select debugger prompt, select .NET 5+ and .NET Core.

*

The default browser launched with the following URL: https://localhost: where is the randomly generated port number.

Close the browser window.

In Visual Studio Code, from the Run menu, select Stop Debugging or press Shift+F5 lớn stop the app.

Select Debug > Start Debugging khổng lồ launch the app.

Visual Studio for Mac launches a browser và navigates to https://localhost:, where is the port number randomly assigned at project creation & is phối in Properties/launch
Settings.json.

Close the browser window.


Examine the project files

The following sections contain an overview of the main project folders và files that you"ll work with in later tutorials.

Pages folder

Contains Razor pages và supporting files. Each Razor page is a pair of files:

A .cshtml tệp tin that has HTML markup with C# code using Razor syntax.A .cshtml.cs file that has C# code that handles page events.

wwwroot folder

Contains static assets, like HTML files, Java
Script files, và CSS files. For more information, see Static files in ASP.NET Core.

appsettings.json

Contains configuration data, lượt thích connection strings. For more information, see Configuration in ASP.NET Core.

Program.cs

Contains the following code:

var builder = Web
Application.Create
Builder(args);// add services to lớn the container.builder.Services.Add
Razor
Pages();var tiện ích = builder.Build();// Configure the HTTP request pipeline.if (!app.Environment.Is
Development()) app.Use
Exception
Handler("/Error"); // The default HSTS value is 30 days. You may want to lớn change this for production scenarios, see https://aka.ms/aspnetcore-hsts. App.Use
Hsts();app.Use
Https
Redirection();app.Use
Static
Files();app.Use
Routing();app.Use
Authorization();app.Map
Razor
Pages();app.Run();The following lines of code in this file create a Web
Application
Builder with preconfigured defaults, địa chỉ Razor Pages tư vấn to the Dependency Injection (DI) container, & builds the app:

var builder = Web
Application.Create
Builder(args);// add services to lớn the container.builder.Services.Add
Razor
Pages();var tiện ích = builder.Build();The developer exception page is enabled by default & provides helpful information on exceptions. Production apps should not be run in development mode because the developer exception page can leak sensitive information.

The following code sets the exception endpoint to lớn /Error và enables HTTP Strict Transport Security Protocol (HSTS) when the tiện ích is not running in development mode:

// Configure the HTTP request pipeline.if (!app.Environment.Is
Development()) app.Use
Exception
Handler("/Error"); // The mặc định HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. App.Use
Hsts();For example, the preceding code runs when the phầm mềm is in production or demo mode. For more information, see Use multiple environments in ASP.NET Core.

The following code enables various Middleware:

app.Use
Https
Redirection(); : Redirects HTTP requests to lớn HTTPS.app.Map
Razor
Pages();: Configures endpoint routing for Razor Pages.app.Use
Authorization(); : Authorizes a user lớn access secure resources. This app doesn"t use authorization, therefore this line could be removed.app.Run(); : Runs the app.

Troubleshooting with the completed sample

If you run into a problem you can"t resolve, compare your code to lớn the completed project. View or download completed project (how khổng lồ download).

Next steps


This is the first tutorial of a series that teaches the basics of building an ASP.NET chip core Razor Pages web app.

For a more advanced introduction aimed at developers who are familiar with controllers và views, see Introduction to lớn Razor Pages. For a video clip introduction, see Entity Framework chip core for Beginners.

If you"re new to lớn ASP.NET vi xử lý core development and are unsure of which ASP.NET bộ vi xử lý core web UI solution will best fit your needs, see Choose an ASP.NET bộ vi xử lý core UI.

At the end of the series, you"ll have an app that manages a database of movies.

In this tutorial, you:


At the kết thúc of this tutorial, you"ll have a working Razor Pages web tiện ích that you"ll enhance in later tutorials.

*

Prerequisites


The Visual Studio Code instructions use the .NET CLI for ASP.NET bộ vi xử lý core development functions such as project creation. You can follow these instructions on mac
OS, Linux, or Windows và with any code editor. Minor changes may be required if you use something other than Visual Studio Code.

Visual Studio 2022 for Mac (latest version)


Important

ungdungfb.com has announced the retirement of Visual Studio for Mac. Visual Studio for Mac will no longer be supported starting August 31, 2024. Alternatives include:

Visual Studio IDE running on Windows in a VM on Mac.

For more information, see Visual Studio for Mac retirement announcement.


Start Visual Studio 2022 và select Create a new project.

*

In the Create a new project dialog, select ASP.NET vi xử lý core Web App, & then select Next.

*

In the Configure your new project dialog, enter Razor
Pages
Movie for Project name. It"s important lớn name the project Razor
Pages
Movie
, including matching the capitalization, so the namespaces will match when you copy & paste example code.

*

Select Next.

In the Additional information dialog, select .NET 6.0 (Long-term support) và then select Create.

*

The following starter project is created:

*

The tutorial assumes familiarity with VS Code. For more information, see Getting started with VS Code.

Change lớn the directory (cd) that will contain the project.

Run the following commands:

dotnet new webapp -o Razor
Pages
Moviecode -r Razor
Pages
Movie
The dotnet new command creates a new Razor Pages project in the Razor
Pages
Movie
folder.

The code command opens the Razor
Pages
Movie
project folder in the current instance of Visual Studio Code.

Visual Studio Code might display a dialog box that asks: Do you trust the authors of the files in this folder?

If you trust all files in the parent folder, select Trust the authors of all files in the parent folder.Select Yes, I trust the authors since the project folder has files generated by .NET.When Visual Studio Code requests that you showroom assets khổng lồ build and debug the project, select Yes. If Visual Studio Code doesn"t offer to showroom build and debug assets, select View > Command Palette & type ".NET" into the search box. From the danh mục of commands, select the .NET: Generate Assets for Build & Debug command.

Visual Studio Code adds a .vscode thư mục with generated launch.json và tasks.json files.

Select File > New Solution.

*

In Visual Studio 2022 for Mac select Web & Console > App > Web Application > Next.

*

In the Configure your new website Application dialog:

Confirm that Target framework is set to the latest .NET 6.x version.Confirm that Authentication is set khổng lồ No Authentication.Select Next.

Name the project Razor
Pages
Movie
and select Create.

*


Select Razor
Pages
Movie
in Solution Explorer, & then press Ctrl+F5 to run without the debugger.

Visual Studio displays the following dialog when a project is not yet configured to use SSL:

*

Select Yes if you trust the IIS Express SSL certificate.

The following dialog is displayed:

*

Select Yes if you agree lớn trust the development certificate.

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

Visual Studio:

Launches the mặc định browser at https://localhost:5001, which displays the apps UI.

Trust the HTTPS development certificate by running the following command:

dotnet dev-certs https --trust
The preceding command doesn"t work on Linux. See your Linux distribution"s documentation for trusting a certificate.

The preceding command displays the following dialog, provided the certificate was not previously trusted:

*

For information on trusting the Firefox browser, see Firefox SEC_ERROR_INADEQUATE_KEY_USAGE certificate error.

In Visual Studio Code, press Ctrl+F5 lớn run the app. At the Select environment prompt, select .NET Core.

The mặc định browser launched with the following URL: https://localhost:5001

Select Debug > Start Debugging lớn launch the app. Visual Studio for Mac launches a browser and navigates to lớn https://localhost:, where is the port number randomly assigned at project creation và is phối in Properties/launch
Settings.json.


Examine the project files

The following sections contain an overview of the main project folders và files that you"ll work with in later tutorials.

Pages folder

Contains Razor pages và supporting files. Each Razor page is a pair of files:

A .cshtml tệp tin that has HTML markup with C# code using Razor syntax.A .cshtml.cs tệp tin that has C# code that handles page events.

wwwroot folder

Contains static assets, like HTML files, Java
Script files, & CSS files. For more information, see Static files in ASP.NET Core.

appsettings.json

Contains configuration data, like connection strings. For more information, see Configuration in ASP.NET Core.

Program.cs

Contains the following code:

var builder = Web
Application.Create
Builder(args);// địa chỉ cửa hàng services lớn the container.builder.Services.Add
Razor
Pages();var tiện ích = builder.Build();// Configure the HTTP request pipeline.if (!app.Environment.Is
Development()) app.Use
Exception
Handler("/Error"); // The default HSTS value is 30 days. You may want khổng lồ change this for production scenarios, see https://aka.ms/aspnetcore-hsts. App.Use
Hsts();app.Use
Https
Redirection();app.Use
Static
Files();app.Use
Routing();app.Use
Authorization();app.Map
Razor
Pages();app.Run();The following lines of code in this tệp tin create a Web
Application
Builder with preconfigured defaults, showroom Razor Pages support to the Dependency Injection (DI) container, & build the app:

var builder = Web
Application.Create
Builder(args);// showroom services lớn the container.builder.Services.Add
Razor
Pages();var ứng dụng = builder.Build();The developer exception page is enabled by default & provides helpful information on exceptions. Production apps should not be run in development mode because the developer exception page can leak sensitive information.

The following code sets the exception endpoint lớn /Error and enables HTTP Strict Transport Security Protocol (HSTS) when the app is not running in development mode:

// Configure the HTTP request pipeline.if (!app.Environment.Is
Development()) app.Use
Exception
Handler("/Error"); // The mặc định HSTS value is 30 days. You may want to lớn change this for production scenarios, see https://aka.ms/aspnetcore-hsts. App.Use
Hsts();For example, the preceding code runs when the phầm mềm is in production or test mode. For more information, see Use multiple environments in ASP.NET Core.

The following code enables various Middleware:

app.Use
Https
Redirection(); : Redirects HTTP requests khổng lồ HTTPS.app.Map
Razor
Pages();: Configures endpoint routing for Razor Pages.app.Use
Authorization(); : Authorizes a user khổng lồ access secure resources. This ứng dụng doesn"t use authorization, therefore this line could be removed.app.Run(); : Runs the app.

Troubleshooting with the completed sample

If you run into a problem you can"t resolve, compare your code lớn the completed project. View or tải về completed project (how khổng lồ download).

Next steps


This is the first tutorial of a series that teaches the basics of building an ASP.NET vi xử lý core Razor Pages website app.

For a more advanced introduction aimed at developers who are familiar with controllers & views, see Introduction lớn Razor Pages.

If you"re new to lớn ASP.NET bộ vi xử lý core development và are unsure of which ASP.NET chip core web UI solution will best fit your needs, see Choose an ASP.NET vi xử lý core UI.

At the over of the series, you"ll have an phầm mềm that manages a database of movies.

In this tutorial, you:


At the end of this tutorial, you"ll have a working Razor Pages web phầm mềm that you"ll enhance in later tutorials.

*

Prerequisites


The Visual Studio Code instructions use the .NET CLI for ASP.NET bộ vi xử lý core development functions such as project creation. You can follow these instructions on mac
OS, Linux, or Windows & with any code editor. Minor changes may be required if you use something other than Visual Studio Code.


In the Create a new project dialog, select ASP.NET core Web Application, & then select Next.

*

In the Configure your new project dialog, enter Razor
Pages
Movie for Project name. It"s important to name the project Razor
Pages
Movie
, including matching the capitalization, so the namespaces will match when you copy & paste example code.

Select Create.

*

In the Create a new ASP.NET core web application dialog, select:

.NET Core and ASP.NET core 5.0 in the dropdowns.Web Application.Create.

*

The following starter project is created:

*

The tutorial assumes familiarity with VS Code. For more information, see Getting started with VS Code.

Change lớn the directory (cd) that will contain the project.

Run the following commands:

dotnet new webapp -o Razor
Pages
Moviecode -r Razor
Pages
Movie
The dotnet new command creates a new Razor Pages project in the Razor
Pages
Movie
folder.

The code command opens the Razor
Pages
Movie
project thư mục in the current instance of Visual Studio Code.

Visual Studio Code might display a dialog box that asks: Do you trust the authors of the files in this folder?

If you trust all files in the parent folder, select Trust the authors of all files in the parent folder.Select Yes, I trust the authors since the project thư mục has files generated by .NET.When Visual Studio Code requests that you địa chỉ assets to build & debug the project, select Yes. If Visual Studio Code doesn"t offer to add build & debug assets, select View > Command Palette & type ".NET" into the search box. From the các mục of commands, select the .NET: Generate Assets for Build and Debug command.

Visual Studio Code adds a .vscode folder with generated launch.json & tasks.json files.

Select File > New Solution.

*

In Visual Studio for Mac earlier than version 8.6, select .NET Core > App > Web Application > Next. In version 8.6 or later, select Web and Console

Leave a Reply

Your email address will not be published. Required fields are marked *