![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
MVC
文章平均质量分 83
smartsmile2012
这个作者很懒,什么都没留下…
展开
-
ASP.NET/C# 获取当前目录、当前完整路径、文件全路径、目录、扩展名、文件名称
using System;using System.IO;namespace ConsoleApp5{ class Program { /* C# 获取当前目录、当前路径、文件全路径、目录、扩展名、文件名称 */ static void Main(string[] args) { ...原创 2018-09-14 14:19:09 · 16204 阅读 · 1 评论 -
asp.net或者MVC定时自动执行某操作
using System;using System.IO;using System.Runtime.CompilerServices;using System.Text;namespace SystemTask{ public class CensusdemoTask { System.Threading.Timer timer; pri原创 2016-12-16 20:04:34 · 10825 阅读 · 1 评论 -
c# 反射得到实体类的字段名称和值,DataTable转List<T>
/// /// 反射得到实体类的字段名称和值/// var dict = GetProperties(model);/// /// 实体类/// 实例化/// public static Dictionary GetProperties(T t){ var ret = new Dictionary(); if (t == null) { return null; } Prop原创 2016-11-18 15:54:21 · 12914 阅读 · 0 评论 -
项目中一些常用操作记录
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.Common;using System.Threading.Tasks;using JianKu.Dal;using JianKu.Model;u原创 2016-12-08 19:02:19 · 1623 阅读 · 0 评论 -
消息队列、OSS常用操作封装
public class MessageQueue { #region Private Properties private const string _accessKeyId = ""; private const string _secretAccessKey = ""; private const string _end原创 2016-11-01 11:26:14 · 2469 阅读 · 0 评论 -
EasyUI DataGrid使用示例
EasyUI DataGrid示例 $(function () { $("#tt").datagrid({ title: "数据分页", url: "easyuihandler.ashx?method=query",原创 2016-11-05 17:06:50 · 18832 阅读 · 0 评论 -
ABP增删改查代码片段
@using System.Web.Optimization@using MultiPageSimpleTask.Entitys.Dtos;@model IList@{ Layout = null; ProductDto productDto = ViewBag.SingleProduct as ProductDto;} Hello World @Sc原创 2016-10-27 11:57:06 · 5140 阅读 · 0 评论 -
项目收集-AutoMapper使用,事务,Json.Net序列化反序列化,代码生成调用等
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using MSCL;using System.Transactions;using AutoMapper;namespace ConsoleApplicati原创 2016-10-25 18:12:32 · 1085 阅读 · 0 评论 -
c#枚举 获取枚举键值对、描述等
using System;using System.Collections.Generic;using System.Collections.Specialized;using System.ComponentModel;using System.Linq;using System.Reflection;using System.Text;using System.Threading原创 2016-09-29 10:24:18 · 8239 阅读 · 0 评论 -
C#无限分级实现,前端WEB页面接收,后台提供层级Json数据
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Text;using System.Data;using System.Collections;using System.Web.UI;using System.Web.UI.WebControl原创 2016-11-03 10:31:09 · 3970 阅读 · 2 评论 -
c# datetime与 timeStamp(unix时间戳) 互相转换
/// /// Unix时间戳转为C#格式时间 /// /// Unix时间戳格式,例如1482115779 /// C#格式时间 public static DateTime GetTime(string timeStamp) { DateTime dt转载 2016-12-19 10:54:20 · 13723 阅读 · 1 评论 -
VS2015 +EF6 连接MYSQL数据库生成实体
已安装软件:VS2015 Mysql服务器使用时:使用EF设计器此时此刻,发现二逼了,咋没有mysql????(好吧,上图是用的别人的,本机已经木有这个没有mysql的界面了)好吧,下面重点: 需要下载安装:1:mysql-for-visualstudi转载 2016-07-08 21:49:08 · 7874 阅读 · 3 评论 -
MVC中全局错误拦截记录日志,WebApi中全局错误拦截以及授权验证401,jquery cors 跨域
using Magic.Tool;using System;using System.Web;using System.Web.Mvc;using System.Web.Routing;//MVC中全局错误拦截namespace Magic.Mvc{ public class MvcApplication : System.Web.HttpApplication ...原创 2018-09-18 09:01:43 · 1995 阅读 · 1 评论 -
C#对图片进行马赛克处理,可控制模糊程度
using System.Drawing;using System.Drawing.Imaging;using System.Web.Mvc;namespace MVC2017_Sample.Controllers{ public class DefaultController : Controller { public ActionResult Inde原创 2017-10-14 09:51:07 · 2089 阅读 · 0 评论 -
WebApi接口返回json,xml,text纯文本等
[Route("api/Message/MessageList/")][HttpGet]public HttpResponseMessage MessageList(){ ResponseResult obj = new ResponseResult(); var pageData = Ydt.ExtLib.DataTableHelper.DataTableToList(re原创 2017-09-20 14:56:05 · 4163 阅读 · 0 评论 -
MVC自定义路由实现URL重写,SEO优化
//App_Start-RouteConfig.cs public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");原创 2017-07-07 10:57:57 · 6209 阅读 · 0 评论 -
ASP.NET/MVC 配置log4net启用写错误日志功能
<!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=169433 --> <!-- 在AssemblyInfo.cs加入 [assembly: log4net.Config.XmlConfigurator(ConfigFile =原创 2016-07-22 22:25:51 · 3568 阅读 · 0 评论 -
MVC 从控制器将数据对象赋值给前端JS对象
@{ Layout = null;} 示例 //将数据对象转换为 JSON 格式,是为了在网页中通过使用JS将数据作为文本进行处理 var data = @Html.Raw(Json.Encode(ViewBag.Data)); for (var i = 0; i < data.length;原创 2017-06-19 09:07:45 · 3175 阅读 · 0 评论 -
执行Sqlserver中waitfor delay延时操作或waitfor time定时操作
#region /// /// 当点击执行查询时发生(异步操作) /// 执行数据库waitfor delay延时存储过程 /// 或者waitfor time定时存储过程 /// private void Button_DoSearch_Click(object sender, EventArgs e) { strin原创 2016-12-19 17:18:24 · 7024 阅读 · 0 评论 -
Asp.net/C#/Mvc 中Cache缓存帮助类
using System;using System.Web;using System.Collections;namespace MSCL{ /// /// Cache辅助类 /// public class CacheHelper { /// /// 获取数据缓存 /// /原创 2016-12-17 16:22:12 · 8243 阅读 · 0 评论 -
MVC中使用Echart后台加载数据 实现饼图、折线图、全国地图数据,单击双击事件等
@{ Layout = null;}@if (false){ } 访问统计 $(function () { ReloadData(原创 2016-12-06 17:01:40 · 4498 阅读 · 0 评论 -
WebApi中直接返回json字符串的方法
[HttpPost]public HttpResponseMessage Upload(){ string json = "{\"result\":\"true\"}"; return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/jso转载 2016-10-10 17:48:50 · 4220 阅读 · 0 评论 -
MVC使用jQuery从视图向控制器传递Model,数据验证,MVC HTML辅助方法小结
//MVC HTML辅助类常用方法记录(1)@Html.DisplayNameFor(model => model.Title)是显示列名,(2)@Html.DisplayFor(modelItem => item.Title)是显示列的内容(3)@Html.ActionLink("Create New", "Create")是超链接,跳转到model中的create页面,引用的是co原创 2016-08-27 22:32:24 · 4149 阅读 · 0 评论 -
Asp.Net MVC4 系列-- 进阶篇之路由(1)
对于Route:[csharp] view plain copy print?routes.MapRoute( name:"Default", url:"{controller}/{action}/{id}", defaults:转载 2016-06-27 16:08:24 · 865 阅读 · 0 评论 -
使用Entify Framework 6.x的事务操作
public void TransactionsTest() { using (var context = new testContext()) { //使用EF事务 在vs2013中先升级Entity Framework框架至6.x //工具 - Nuget程序包管理原创 2016-06-12 08:53:27 · 1129 阅读 · 0 评论 -
手动打包MVC项目成Web Deploy包,发布至服务器
①确保服务器上安装了Web Deploy,可以使用微软Web Paltform Installer安装。https://www.microsoft.com/web/downloads/platform.aspx②VS中生成Web Deploy打包文件③确保系统服务中“Web部署代理服务”已经启动④查看打包文件生成目录,其中“MvcShopping.deploy.原创 2016-06-11 21:54:20 · 3576 阅读 · 0 评论 -
MVC中Controller控制器相关技术
第6章Controller相关技术Controller(控制器)在ASP.NET MVC中负责控制所有客户端与服务器端的交互,并 且负责协调Model与View之间的数椐传递,是ASP.NET MVC整体运作的核心角色,非常重6.3 Controller的运行过程在ASP.NET MVC中并非所有动作方法都必须回传ActionResult类别或其衍生类别,也可以直接使用.NET内建的基本数据转载 2016-06-26 21:49:39 · 7588 阅读 · 0 评论 -
Entity Framework 之Code First自动数据迁移
using MvcShopping.Migrations;using MvcShopping.Models;using System;using System.Collections.Generic;using System.Data.Entity;using System.Linq;using System.Web;using System.Web.Http;using Syst原创 2016-06-09 21:30:32 · 2689 阅读 · 0 评论 -
Asp.Net MVC4 系列--进阶篇之路由 (2)
上一篇介绍了Asp.Net MVC 中,从Http Pipeline上接收到请求如何匹配,匹配限制,以及如何控制在指定命名空间查找,解析出controller和action,并传参。 这篇主要介绍如何使用路由完成url生成,实现页面跳转,以及customize一个路由。 在view中生成一个url连接 路由配置使用默认生成的:routes.MapRoute(转载 2016-06-28 08:53:25 · 544 阅读 · 0 评论 -
MVC调用部分视图PartialView
using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace Demo2017.Models{ /* ~/Models/LoginModel.cs */ public class LoginModel { public str原创 2016-06-28 10:32:07 · 6919 阅读 · 0 评论 -
MVC中@RenderBody、@RenderSection、@RenderPage、@Html.RenderPartial、Html.RenderAction的作用和区别
1、@RenderBody() 作用和母版页中的服务器控件类似,当创建基于此布局页面的视图时,视图的内容会和布局页面合并,而新创建视图的内容会通过布局页面的@RenderBody()方法呈现在标签之间。 这个方法不需要参数,而且只能出现一次。 2、@RenderPage 从名称可以猜出来这个方法是要呈现一个页面。比如网页中固定的头部可以单独放在一个共享的视图文件中,转载 2016-06-28 16:15:38 · 5047 阅读 · 0 评论 -
c# 【MVC】WebApi开发实例
using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.Linq;using System.Web;namespace ProductStore.Models{ //商品实体类 public class Product转载 2016-06-08 14:39:11 · 24444 阅读 · 0 评论 -
c# 【MVC】WebApi返回各种类型(图片/json数据/字符串)
using System.IO;/// /// WebApi返回图片/// public HttpResponseMessage GetQrCode(){ var imgPath = @"D:\ITdosCom\Images\itdos.jpg"; //从图片中读取byte var imgByte = File.ReadAllBytes(imgPath);转载 2016-06-08 15:07:00 · 11343 阅读 · 0 评论 -
c# 【MVC】WebApi设置返回Json
public static HttpResponseMessage toJson(Object obj) { String str; if (obj is String || obj is Char) { str = obj.ToString(); }转载 2016-06-08 16:04:51 · 4185 阅读 · 0 评论 -
【MVC】MvcPager分页及边界传递数据示例
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using MvcTest.Models;using Webdiyer.WebControls.Mvc;namespace MvcTest.Controllers{ pu原创 2016-06-10 21:56:34 · 2466 阅读 · 0 评论 -
【MVC】会员注册/登录,普通验证,会员名是否注册Ajax验证以及会员邮件验证实现原理
using System;using System.Collections.Generic;using System.ComponentModel;using System.ComponentModel.DataAnnotations;namespace MvcTest.Models{ public partial class Member { publ转载 2016-06-11 11:14:44 · 1614 阅读 · 0 评论 -
MVC中重写RoleProvider角色管理
/* 数据表SQL脚本if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_UsersInRoles_Roles]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[UsersInRoles] DROP CONSTRAINT转载 2016-07-01 17:56:34 · 1622 阅读 · 0 评论 -
MVC 中获取Json数据
@{ ViewBag.Title = "json示例项目";}@Scripts.Render("~/bundles/jquery")json示例项目View GetJsonData1 GetJsonData2 暂无数据 function getJsonData() { var str = ""; $.getJS原创 2016-06-29 17:11:43 · 3840 阅读 · 0 评论 -
ASP.NET MVC AJAX的调用示例
@{ ViewBag.Title = "Home Page"; //下面引用Jquery和unobtrusive-ajax}@Scripts.Render("~/bundles/jquery") @{ //设置ajaxOptions var ajaxOptions = new AjaxOptions() { OnSuccess = "S原创 2016-06-27 14:44:24 · 5089 阅读 · 0 评论 -
MVC中View界面数据呈现示例
@using System.Text;@model List@{ ViewBag.Title = "测试程序"; }接收控制器传递的数据 @ViewBag.UserName显示Model的名称:@Html.DisplayNameFor(model => model[0])现在时间:@DateTime.Now启用状态:@ViewBag.Title多行C#代码@{ v原创 2016-06-24 23:21:45 · 9181 阅读 · 0 评论