- 博客(72)
- 资源 (6)
- 收藏
- 关注
转载 MVC EF Code First
1 在Models里面创建类,用[Key]特性指定主键;2 在Model里面增加导航属性;3 在web.config里面增加连接字符串4 创建继承于DbContext的类5 创建Controller类,生成Index视图6 在Controller类的Index()里面,通过context.Database.CreateIfNotExist()//BookInfo.csusing System;us...
2018-04-26 17:20:51 277
转载 MVC EF Model First
1 在Models下新建实体数据模型Model.edmx2 在Model.edmx中点右键建立各个实体,增加Scalar Property3 空白处点右键,添加关系,勾选增加外键4 保存Model.edmx, 空白处点右键,选择从模型生成数据库既可...
2018-04-26 16:48:53 253
转载 MVC WebApi的两种访问方法
//UserInfoControllerusing ClassLibrary;using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Net.Http;using System.Web.Http;namespace WebApiExam.Controllers{ ...
2018-04-25 22:15:42 5436
转载 MVC CRUD 的两种方法
//Index.cshtml@model IQueryable<MvcExam2.Models.Product>@{ Layout = null;}<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width" /> &
2018-04-25 22:04:57 595
转载 MVC EF 导航属性
@model IQueryable<EFExam.Models.CategoryProductViewModel>@{ Layout = null;}<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width" />
2018-04-25 15:43:01 1078
转载 MVC EF两种查询方法
@*@model IQueryable<EFExam.Models.Product>*@@model IQueryable<EFExam.Models.ProductViewModel>@{ Layout = null;}<!DOCTYPE html><html><head> <meta name="viewport" ..
2018-04-25 14:08:49 5533
转载 MVC WebApi
两种web服务•SOAP风格:基于方法,产品是WebService•REST风格:基于资源,产品是WebAPI对于数据的增、删、改、查,提供相对的资源操作,按照请求的类型进行相应处理,主要包括Get(查)、Post(增)、Put(改)、Delete(删),这些都是http协议支持的请求方式在APIController中定义crud的方法,名称可以自定义,如果对应相应的资源操作,可以使用特性约束主要...
2018-04-24 22:02:43 161
转载 MVC 行为过滤器
using FilterExam.Fiter;using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace FilterExam.Controllers{ public class HelloController : Control...
2018-04-24 20:57:16 195
转载 MVC 身份验证和异常处理过滤器
两种使用方式:1自定义类继承自相应的类或接口,重写方法,作为特性使用2 在控制器类中重写方法特性方式的使用注意:如果继承自接口需要让类实现FilterAttribute,才可以作为特性使用使用方式1:作为Controller或Action的特性使用方式2:在Global中注册为全局过滤器,应用于所有的Controller的Action参数类均继承自ControllerContext,主要包含属性请...
2018-04-24 19:47:32 405
转载 MVC 校验
@model MVCFirst.Models.Person@{ Layout = null;}<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width" /> <title>Add</title&
2018-04-23 22:16:24 98
转载 MVC 异步调用
@{ Layout = null;}<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width" /> <title>Index</title> <script src=
2018-04-23 21:53:32 288
转载 MVC 调试路由
1.添加引用RouteDebug.dll2 修改Global.asax,切记调试过后要删掉using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Http;using System.Web.Mvc;using System.Web.Optimization;u...
2018-04-23 15:12:11 137
转载 MVC 自定义路由规则
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using System.Web.Routing;namespace FirstMVC{ public class RouteConfig { public static...
2018-04-23 14:59:15 767
转载 MVC 自动装配
//HelloController.csusing FirstMVC.Models;using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace FirstMVC.Controllers{ public class HelloCon...
2018-04-23 14:57:18 219
转载 MVC 直接或间接继承自ActionResult的类型
•ViewResult:使用View()可以指定一个页面,也可以指定传递的模型对象,如果没有指定参数则表示返回与Action同名的页面•ContentResult:使用Content(string content)返回一个原始字符串•RedirectResult:使用Redirect(stringurl)将结果转到其它的Action•JsonResult:使用Json(object
2018-04-23 09:19:26 318
转载 MVC 创建强类型视图
•在ViewModel中创建一个类型•在Action中为ViewData.Model赋值•在View中使用“@model类型”设置14 手动创建强类型视图•在ViewModel中创建一个类型•在Action中为ViewData.Model赋值•在View中使用“@model类型”设置...
2018-04-22 21:06:07 1140
转载 MVC HtmlHelper
1专门用于MVC的链接方式:Html.Action(“Home”,“Index”),会根据路由规则生成a标记,并且在运行时可以进行有效性检查,不需要用户点击链接后才知道链接出错了2 Raw:输出3 Encode:进行Html编码4 Action:服务器端其它页面5 表单控件•类型一:Html.**(),以字符串为参数•类型二:Html.**For(),以Expression<Func<...
2018-04-22 20:44:09 98
转载 MVC Razor视图引擎
强大的@:表示使用C#代码,相当于aspx中的<%%>可以完成输出功能当遇到html标签时会认为C#代码结束,贪婪匹配后面的内容,如@a1会认为是变量a1,如@a<br>1会认为是变量a会对标签内容进行Html编码注释:@*注释内容*@注意:@变量表示输出,结尾不加分号l引入命名空间:@using命名空间;...
2018-04-22 20:42:11 168
转载 MVC 组件之间的关系
View和Controller都可以直接请求Model 但是Model不依赖View和controllerlController可以直接请求View来显示具体页面 View不依赖ControllerView可以通过另外的方式来请求Controller...
2018-04-22 19:19:32 1842 1
转载 Web应用程序和网站的区别
1项目就是一个应用程序。在VS中查看的时候,项目中建立的一般处理程序,有两个文件,网站只有一个。写个代码测试,发现在代码层次上没有2再有就是项目中的一般处理程序有命名空间,而网站中的没有。WEB网站每一个页面(ashx页面)都是一个独立的程序,一个页面出错了不会影响到另外一个页面(演示).3项目中建立完一个文件(或修改了一个文件),一定要重新生成,生成的目的就是将项目生成对应的dll文件放在bin...
2018-04-21 11:36:22 2581
转载 WebForm- CRUD
//UserInfoList.html<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>用户列表页面</title>
2018-04-19 23:17:53 257
转载 WebForm- Get请求
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title><meta charset="utf-8&
2018-04-19 09:04:50 438
转载 WebForm- 用隐藏域解决Http无状态问题
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title></head><body> <form method="post" actio
2018-04-19 09:04:05 312
转载 WebForm- POST请求
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title><meta charset="utf-8&
2018-04-18 23:30:14 1369
转载 WebForm- FirstWeb
//html<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title><meta charset=&qu
2018-04-18 22:52:35 256
转载 WebForm-HTTP 状态码
状态代码有三位数字组成,第一个数字定义了响应的类别,且有五种可能取值:1xx:指示信息--表示请求已接收,继续处理2xx:成功--表示请求已被成功接收、理解、接受3xx:重定向--要完成请求必须进行更进一步的操作4xx:客户端错误--请求有语法错误或请求无法实现5xx:服务器端错误--服务器未能实现合法的请求常见状态代码、状态描述、说明:200 OK //客户端请求成功4...
2018-04-18 16:58:19 191
原创 C# TCP 通讯
//接收using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Net;using System.Net.Sockets;using S...
2018-04-18 11:07:39 633
原创 C# 发送邮件
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Net;using System.Net.Mail;using System.Text;using System...
2018-04-18 10:28:02 174
原创 C# WebBrowser的使用
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.F...
2018-04-18 09:31:00 3132
原创 C# WebRequest WebResponse的使用
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Threa...
2018-04-18 08:55:49 772
原创 C# WebRequest WebResponse的使用
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Threa...
2018-04-18 08:41:43 652
原创 C# WebClient的使用
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Net;using System.Text;using System.Threa...
2018-04-18 08:36:17 2466
原创 C#基于用户和角色的验证,服务端web 客户端wpf
应用程序服务<?xml version="1.0"?><!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --><configuration> ...
2018-04-13 16:55:46 776
原创 C# 声明基于角色的安全性
using System;using System.Collections.Generic;using System.Linq;using System.Security;using System.Security.Permissions;using System.Security.Principal;using System.Text;using System.Threading;using S...
2018-04-13 10:16:39 187
原创 C# WindowsPrincipal(Windows规则)的使用
using System;using System.Collections.Generic;using System.Linq;using System.Security.Principal;using System.Text;using System.Threading;using System.Threading.Tasks;namespace WindowsPrincipal{ cla...
2018-04-13 10:07:11 843
原创 C# System.Timers.Timer的使用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace TimersTimer{ class Program { static void Ma...
2018-04-11 15:26:01 1623
原创 C# System.Threading.Timer的使用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace ThreadTimerExam{ class Program { static voi...
2018-04-11 15:14:26 9223
原创 C# Task的使用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;namespace TaskExam{ class Program { static void Main(...
2018-04-11 15:01:11 197
ASP.NET MVC 5高级编程 第5版(中文版带书签)
2018-07-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人