Asp.net MVC 3 Convention over configuration 约定胜于配置

简介: 这个约定是我在Profession Asp.net MVC 3 这本书上看到写下的笔记,作为一个总结。因为原书是英文的,所以可能会有翻译不对的地方,我尽量使用原文。 MVC is designed around some sensible convention-based defaults that can be overridden as needed.This concept is commonly referred to as “Convention over configuration”. MVC被设计用来遵循以约定为基础。

这个约定是我在Profession Asp.net MVC 3 这本书上看到写下的笔记,作为一个总结。因为原书是英文的,所以可能会有翻译不对的地方,我尽量使用原文。

MVC is designed around some sensible convention-based defaults that can be overridden as needed.This concept is commonly referred to as “Convention over configuration”.

MVC被设计用来遵循以约定为基础。

约定胜于配置在一些年前的Ruby on Rails 很流行,它最基本的定义是:

We know,by now,how to build a web application.Let’s roll that experience into the framework so we don’t have to configure absolutely everything,again.

我们知道,至少到目前为止,如何去创建一个Web程序。我们把我们的经验加入到框架中,我们就不必去配置任何必须的事情。

You can see this concept at work in asp.net MVC by taking a look at the three core directories that make the application work:

  • Controllers
  • Models
  • Views

You don’t have to set these folder names in the web.config file-----they are just expected to be there by convention.This saves you the work of having to edit an XML file like your web.config,for example ,in order to explicitly(显式的) tell the MVC engine.”You can find my views in the Views directory”-------it already knows.It’s convention.这就是约定

我又回来了,回到了技术最前线,
相关文章
|
16天前
|
前端开发 Java 应用服务中间件
Springboot对MVC、tomcat扩展配置
Springboot对MVC、tomcat扩展配置
|
3月前
|
开发框架 前端开发 .NET
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
42 0
|
1月前
|
开发框架 前端开发 .NET
进入ASP .net mvc的世界
进入ASP .net mvc的世界
29 0
|
1月前
mvc.net分页查询案例——mvc-paper.css
mvc.net分页查询案例——mvc-paper.css
5 0
|
1月前
|
开发框架 前端开发 .NET
C# .NET面试系列六:ASP.NET MVC
<h2>ASP.NET MVC #### 1. MVC 中的 TempData\ViewBag\ViewData 区别? 在ASP.NET MVC中,TempData、ViewBag 和 ViewData 都是用于在控制器和视图之间传递数据的机制,但它们有一些区别。 <b>TempData:</b> 1、生命周期 ```c# TempData 的生命周期是短暂的,数据只在当前请求和下一次请求之间有效。一旦数据被读取,它就会被标记为已读,下一次请求时就会被清除。 ``` 2、用途 ```c# 主要用于在两个动作之间传递数据,例如在一个动作中设置 TempData,然后在重定向到另
100 5
|
3月前
|
IDE 前端开发 JavaScript
【C#】C# 开发环境配置(Rider 一个.NET 跨平台集成开发环境)
【1月更文挑战第26天】【C#】C# 开发环境配置(Rider 一个.NET 跨平台集成开发环境)
|
3月前
|
XML 前端开发 定位技术
C#(NET Core3.1 MVC)生成站点地图(sitemap.xml)
C#(NET Core3.1 MVC)生成站点地图(sitemap.xml)
25 0
|
3月前
|
前端开发
.net core mvc获取IP地址和IP所在地(其实是百度的)
.net core mvc获取IP地址和IP所在地(其实是百度的)
124 0
|
3月前
|
前端开发 Java Spring
【Spring MVC】SpringMVC自动配置
【1月更文挑战第14天】【Spring MVC】SpringMVC自动配置
|
4月前
|
前端开发 JavaScript Java
Spring Boot中Spring MVC的基本配置讲解与实战(包括静态资源配置,拦截器配置,文件上传配置及实战 附源码)
Spring Boot中Spring MVC的基本配置讲解与实战(包括静态资源配置,拦截器配置,文件上传配置及实战 附源码)
53 1