//文件下载,里面有exe可直接运行
23
2013
08
22
2013
08
.net mvc中上传图片生成缩略图
Code:
#region CreateThumbnail /// <summary> /// 生成缩略图 /// </summary> /// <param name="uploadObject">上传的HttpPostedFile或图片物理路径</param> /// <param name="uploaddir">上传文件夹相对路径</param> /// <param name="ext">后缀(如:.jpg)</param> /// <param name="t_width">缩略图宽</param> /// <param name="t_height">缩略图高</param> /// <param name="filename">文件夹,不含路径和后缀</param> /// <param name="tm">枚举类-缩略图的样式</param> /// <returns>返回生成图片的路径</returns> public static string CreateThumbnail(object uploadObject, string uploaddir, string ext, int t_width, int t_height, string filename, ThumbModel tm) { System.Drawing.Image thumbnail_image = null; System.Drawing.Image original_image = null; System.Drawing.Bitmap final_image = null; System.Drawing.Graphics graphic = null; MemoryStream ms = null;
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
09
2013
08
谈.net mvc开发中gzip压缩的应用
压缩view的内容,可加过滤器
public class GzipFilter : ActionFilterAttribute { public override void OnResultExecuting(ResultExecutingContext filterContext) { string acceptEncoding = filterContext.HttpContext.Request.Headers["Accept-Encoding"]; if (String.IsNullOrEmpty(acceptEncoding)) return; var response = filterContext.HttpContext.Response; acceptEncoding = acceptEncoding.ToUpperInvariant(); if (acceptEncoding.Contains("GZIP")) { response.AppendHeader("Content-Encoding", "gzip"); response.Filter = new GZipStream(response.Filter, CompressionMode.Compress); } else if (acceptEncoding.Contains("DEFLATE")) { response.AppendHeader("Content-Encoding", "deflate"); response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress); } } }
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
01
2013
08
学习并使用了两种linq to entity 的实现sql关键字in的查询方法
//构造Lambda语句
private static Expression<Func<TElement, bool>> BuildWhereInExpression<TElement, TValue>(Expression<Func<TElement, TValue>> propertySelector, IEnumerable<TValue> values) { ParameterExpression p = propertySelector.Parameters.Single(); if (!values.Any()) return e => false; var equals = values.Select(value => (Expression)Expression.Equal(propertySelector.Body, Expression.Constant(value, typeof(TValue)))); var body = equals.Aggregate<Expression>((accumulate, equal) => Expression.Or(accumulate, equal)); return Expression.Lambda<Func<TElement, bool>>(body, p); }
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览: