随笔分类 - asp.net mvc
摘要:MVC实现Excel导出功能,今天来记录一下. 采取了最简单的方法.(转载)用的是Html拼接成Table表格的方式,返回 FileResult输出一个二进制的文件.第一种:使用FileContentResult// // 摘要: // 通过使用文件内容,内容类型...
阅读全文
摘要:ASP.NET 获取来源网站的网址,获取上一网页的网址,获取来源网页的URL,获取上一网页的URLUri Url = HttpContext.Current.Request.UrlReferrer; HttpContext.Current.Request.Url.PathAndQuery 获取当前页面地址在asp.net中获得来源网址代码如下:Request.UrlReferrer.AbsoluteUri在asp.net中获得IP地址代码如下:Request.UserHostAddress装载:http://www.cnblogs.com/henw/archive/2011/05/18...
阅读全文
摘要:运行程序提示:不支持关键字: “userid”。找了很久在一篇博客里面提示web.config数据库字符串链接出错。
阅读全文
摘要:URL的获取很简单,ASP.NET通用: 【1】获取 完整url (协议名+域名+虚拟目录名+文件名+参数)string url=Request.Url.ToString();【2】获取 虚拟目录名+页面名+参数:string url=Request.RawUrl; (或 string url=Request.Url.PathAndQuery;)【3】获取 虚拟目录名+页面名: string url=HttpContext.Current.Request.Url.AbsolutePath; (或 string url= HttpContext.Current.Request.Path;)【..
阅读全文
摘要:一个简单的asp.net mvc3分页using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Web.Mvc;using System.Web.Mvc.Html;namespace System.Web.Mvc.Html{ public static class ExtensionMethods { /// <summary>/// 创建分页链接/// </summary> ...
阅读全文
摘要:1、1自定义view显示,IView iv = new RazorView(ControllerContext, "/Views/InfoModel/ViewPage1.cshtml", "", true, new List<string>{"cshtml","aspx"});return View(iv, DAL.GetByID(id));
阅读全文
摘要:RenderAction 和RenderPartial的功能都是在页面呈现部分视图,有了他们对代码重用,统一管理很是方便。相同的部分不同的部分RenderAction都是作为分部试图显示在母版页必需建立Action和view,优点是:逻辑层次清晰,控制更灵活。缺点:必需建立Action.RenderPartial必需建立view,优点是:使用简单,代码较少。缺点:不利于重构,需要提供操作数据.
阅读全文
摘要:这些天都在研究asp.net mvc 由于.net 基础薄弱完全是个菜鸟,遇到了很多麻烦,在使用asp.net mvc +ef code first添加记录遇到一个错误:一个实体对象不能由多个 IEntityChangeTracker 实例引用,通过百度谷歌搜索,本人的解决方法是:public partial class Category { public int ID { get; set; } [Display(Name = "栏目名称")] [StringLength(50), Required(ErrorMessage = "栏目名称不能...
阅读全文
摘要:Request.QueryString NameValueCollection GET variables sent with this requestRequest.Form NameValueCollection POST variables sent with this requestRequest.Cookies HttpCookieCollection Cookies sent by the browser with this requestRequest.Http Method string The HTTP method (verb, such as GET or POST) u
阅读全文
摘要:介绍asp.net mvc 之 asp.net mvc 3.0 新特性之 Model:通过 Data Annotations 与 jQuery 的结合实现服务端和客户端的双重验证 双重验证中,使客户端实现远程的异步验证 自定义Data Annotations 与 jQuery,以实现自定义的双重验证 示例1、Model 中通过 Data Annotations 与 jQuery 的结合实现服务端和客户端的双重验证Web.configview sourceprint?<configuration> <!-- 要实现服务端和客户端的双重验证,需要做如下配置,因为双重验证中的客户端
阅读全文
摘要:介绍asp.net mvc 之 asp.net mvc 3.0 新特性之 Controller:Global Action Filter可以在标记为 ChildActionOnly 的 Action 上使用 OutputCacheViewBag新增了一些 Action Result示例1、Global Action Filter 的 DemoGlobal.asax.cs(注册全局的 Action Filter)view sourceprint?protected void Application_Start() { AreaRegistration.RegisterAllAreas(); Re
阅读全文

浙公网安备 33010602011771号