1. 程式人生 > >探索ASP.NET MVC5系列之~~~4.模型篇---包含模型常用特性和過度提交防禦

探索ASP.NET MVC5系列之~~~4.模型篇---包含模型常用特性和過度提交防禦

@model Register

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Register</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form-group">
            @Html.LabelFor(model => model.Age, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Age, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Age, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Money, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Money, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Money, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.NiName, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.NiName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.NiName, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Pass, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Pass, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Pass, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.RPass, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.RPass, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.RPass, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.CreateTime, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.CreateTime, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CreateTime, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

相關推薦

探索ASP.NET MVC5系列~~~4.模型---包含模型常用特性過度提交防禦

@model Register @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>Register

探索ASP.NET MVC5系列~~~5.快取(頁面快取+二級快取)

其實任何資料裡面的任何知識點都無所謂,都是不重要的,重要的是學習方法,自行摸索的過程(不妥之處歡迎指正) 這次來篇放鬆的,咱們不要老是說安全相關的東西。快取這東西並不是MVC獨有的,N年前就有了,簡單介紹一下平時專案裡面使用的(Redis,Memcache等下次說)  1.頁面快取:

探索ASP.NET MVC5系列~~~1.基礎---必須知道的小技能

其實任何資料裡面的任何知識點都無所謂,都是不重要的,重要的是學習方法,自行摸索的過程 MVC==>Model View Controller  Model ====>模型就是要去顯示,儲存,建立,更新和刪除的物件(實體) View =====>檢視是使用者看到並與之互動的介

探索ASP.NET MVC5系列~~~2.檢視(上)---包含XSS防禦非同步分部檢視的處理

其實任何資料裡面的任何知識點都無所謂,都是不重要的,重要的是學習方法,自行摸索的過程(不妥之處歡迎指正) 4.共用其他檢視 不同控制器渲染同一個檢視檔案。這個應用場景還是比較多的,比如同樣是Article的集合,一個是顯示最新文章列表,一個是顯示文章列表,一個是顯示編輯推薦文章列表,基

探索ASP.NET MVC5系列~~~3.檢視(下)---包含常用表單暴力解猜防禦

其實任何資料裡面的任何知識點都無所謂,都是不重要的,重要的是學習方法,自行摸索的過程(不妥之處歡迎指正) 這幾天忙著幫別人普及安全,今天就把這篇文章結束掉,明天講下 “過度提交” 的防禦。這次開篇就激烈點==》爆破演示: 開啟Burp   設定監聽埠==》8080 設定一下代理:

(視訊)asp.net core系列k8s叢集部署視訊

0、前言 應許多網友的要求,特此錄製一下k8s叢集部署的視訊。在錄製完成後發現視訊的聲音存在一點瑕疵,不過不影響大家的觀感。 由於B站的賬號等級不夠無法上傳視訊因此先放在youku上(存在廣告),請大家多多包涵。 一、視訊說明 1、視訊地址: 如果有不懂,或者有疑問的歡迎留言。視訊分為兩段。 第一

ASP.NET MVC 系列 (強型別HTML輔助方法使用)

強型別輔助方法及及相關普通方法介紹一、普通Html輔助方法 1、@Html.Lable(元素名稱,元素值,元素屬性) 示例: @Html.Lable("GenreName","流行",new { @class="validation" }) 渲染之後程式碼如下 <la

asp.net core 系列 20 EF基於數據模型創建數據庫

右鍵 tid 不支持 conn ddd man lse password ces 一.概述   本章使用 Entity Framework Core 構建執行基本數據訪問的 ASP.NET Core MVC 應用程序。使用遷移(migrations)基於數據模型創建數據庫

asp.net core 系列Performance的 Response compression(響應壓縮)

本文,幫助瞭解響應壓縮的一些知識及用法(大部分翻譯於官網,英文水平有限,不準確之處,歡迎指正)。 什麼是響應壓縮?響應壓縮簡單的說就是為了減少網路頻寬,而把返回的響應壓縮,使之體積縮小,從而加快響應的一種技術(個人理解) 網路頻寬是有限的資源。減少響應(response)的大小通常可以增加應用的響應性(即

asp.net core 系列Response caching(1)

這篇文章簡單的講解了response caching: 講解了cache-control,及對其中的頭和值的作用,及設定來控制response caching; 簡單的羅列了其他的快取技術:In-memory caching , Distributed Cache , Cache Ta

asp.net core 系列Response caching Distributed caching(3)

這篇文章講解分散式快取,即 Distributed caching in ASP.NET Core   Distributed caching in ASP.NET Core 分散式快取是可以在多個應用服務上共享的快取,比較經典的用法是作為多個應用伺服器的一個可到達的外部服務。分散式快取可以提

asp.net core 系列Startup

這篇文章簡單記錄 ASP.NET Core中 ,startup類的一些使用。  一.前言 在 Startup類中,一般有兩個方法: ConfigureServices 方法: 用來配置應用的 service 。  Configure 方法:建立應用的請求處理管道 它們都在

asp.net core 系列Dependency injection(依賴注入)

這篇文章主要講解asp.net core 依賴注入的一些內容。 ASP.NET Core支援依賴注入。這是一種在類和其依賴之間實現控制反轉的一種技術(IOC). 一.依賴注入概述 1.原始的程式碼 依賴就是一個物件的建立需要另一個物件。下面的MyDependency是應用中其他類需要的依賴: p

asp.net core 系列Configuration

在ASP.NET Core中的App configuration 是通過configuration providers基於key-value對建立的。Configuration providers讀取配置檔案到key-value,從多種配置源中: Azure key Vault Command-lin

asp.net core 系列靜態檔案

這篇講解asp.net core中的靜態檔案(大致翻譯於官網)。 靜態檔案,例如HTML,CSS, images和JavaScript. 要想直接被客戶端訪問,需要做一些配置。 一.Serve static files(提供靜態檔案服務) 靜態檔案儲存在專案的web root 目錄下。預設的目錄是<

Asp.net Core 系列--3.領域、倉儲、服務簡單實現

ChuanGoing 2019-11-11     距離上篇近兩個月時間,一方面時因為其他事情耽擱,另一方面也是之前準備不足,關於領域驅動有幾個地方沒有想通透,也就沒有繼續碼字。目前網路包括園子裡大多領域驅動設計的文章,關於倉儲者一層都沒有詳細的說明,只是簡單的一筆帶過:領域驅

Asp.net Core 系列--5.認證、授權與自定義許可權的實現

ChuanGoing 2019-11-24   asp.net core系列已經來到了第五篇,通過之前的基礎介紹,我們瞭解了事件訂閱/釋出的eventbus整個流程,初探dapper ORM實現,並且簡單的介紹了領域模型、領域倉儲及服務實現,結合上一篇的日誌、錯誤處理及事務和本篇將要介紹的許可權,大

asp.net core 系列4. 更高更強的路由

# 0. 前言 在之前我們介紹了請求通過路由尋找到控制器,以及控制器與檢視的資料流轉。那麼,我們回過頭來,再看看路由的一些其他用法。 # 1. 路由屬性(Route Attribute) 按照英文的直接翻譯,Routing Attribute 的意思是路由屬性,但實際上 Attribute在微軟的官方稱

ASP.NET 5系列教程(七)完結-解讀代碼

工程 display esp with isp bow use 一個 要求 ??在本文中,我們將一起查看TodoController 類代碼。[Route] 屬性定義了Controller的URL 模板:[Route("api/[controller]")] 全部符合該模

asp.net core系列 76 Apollo 快速安裝模式下填坑ASP.NetCore結合使用

前言:由於公司佔時沒有運維,出於微服務的需要,Apollo只能先裝在windows 阿里雲上跑起來,由於環境及網路等問題,在安裝過程中遇到很多坑,算是一個個坑填完後,最終實現。   一. java jdk環境   java jdk 1.8下載地址: https://www.oracle.c