Bundle javascripts safely in ASP.NET MVC 01 April 2014 Jeff ASP.NET, MVC, C# Problem: The other day I spent a lot of time to figure out that why my web application didn’t work correctly is because of the ASP.NET MVC default JavaScript bundle renamed the function name of Canva... [More]
Replace Telerik window with jquery-ui dialog 28 February 2014 Jeff ASP.NET, C#, JavaScript When you need to display some information via pop up window, it's better to use jquery-ui dialog than Telerik window. Not only because the Telerik is not supported any more, but also because the jquer... [More]
使用HttpHandler防止图片盗链 01 October 2011 Jeff C#, ASP.NET 一、摘要 对于你自己网站上的图片,你可能会希望它们只显示在自己网站的页面上,而当别人的网站引用它们时,不给予显示,或者显示一张自定义的警告图片,或者在图片上加上一个水印信息,告诉浏览者此图片是来自你的网站的。 使用ASP.NET的HttpHandler可以很方便地达到这样的效果。 二、实现步骤 1. 在网站项目中添加一个类文件,实现IHttpHandler接口 2. 配置Web.Conf... [More]
ASP.NET MVC 3 Razor Engine 给页面添加头元素的最佳实践 27 July 2011 Jeff ASP.NET, C# 在实际应用中,会有给页面元素添加头元素的需要。比如要在页面文档中添加SEO数据如description、keywords等,或者在文档头部添加CSS样式、javascript 脚本等。而这些不在ASP.NET MVC 3 Razor Engine的默认特性中。本文给出了增加此特性的最佳决方案。 [More]
Best Practices for Localization of ASP.NET MVC 3 13 June 2011 Jeff ASP.NET [中文版] Note: The original article is here: http://geekswithblogs.net/shaunxu/archive/2010/05/06/localization-in-asp.net-mvc-ndash-3-days-investigation-1-day.aspx. It was written by Shaun. This articl... [More]
ASP.NET MVC 3 本地化最佳实践 12 June 2011 Jeff ASP.NET [English version] 注意:原文在这儿:http://geekswithblogs.net/shaunxu/archive/2010/05/06/localization-in-asp.net-mvc-ndash-3-days-investigation-1-day.aspx,是Shaun写的。 这篇文章可以看成是它的升级版。 相关文件下载: 示例工程文件:z... [More]
ASP.NET 获取服务器上页面的客户端HTML源码 10 January 2011 Jeff ASP.NET, C# 首先介绍一下通过发送Http请求来获取某个网页的HTML响应的方法,代码如下: public string GetWebPageSource(string url) { Uri uri = new Uri(url); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri); ... [More]
ASP.NET 网站遇到“访问IIS元数据库失败”的解决方案 04 January 2011 Jeff ASP.NET 问题: 访问ASP.NET网站时,遇到如下错误: 访问IIS元数据库失败。 用于运行ASP.NET 的进程帐户必须具有对IIS元数据库(如IIS://servername/W3SVC)的读访问权。有关如何修改元数据库权限的信息,请参见http://support.microsoft.com/?kbid=267904。 解决方案: 1. 打开cmd命令行,进入 C:\WINDOWS\Mic... [More]
使用iTextSharp进行PDF编程时的The document has no pages.错误 17 December 2010 Jeff 一、问题 我使用iTextSharp生成PDF文件,今天碰到一个The document has no pages.的错误。它发生于 document.Close() 语句处。 二、原因 经排查,报告这个错误,是由于在PDF页中插入了表格,但是插入表格中的单元格数量与行列数的乘积不相等引起的。比如插入了一个2行2列的表格,但是在使用循环插入单元格的过程中,只插入了3个单元格,就会引发此错... [More]
使用360 C盘搬家后,Visual Studio 添加新项中我的模板丢失问题的解决办法 10 December 2010 Jeff ASP.NET, C# 我使用360 C盘搬家后,在用 Visual Studio 添加新项时,突然发现自己以前的创建的模板消失了! 上网没找到解决办法,后来自己分析了一下,成功解决。 步骤如下: 1. 打开我的文档,依次进入“Visual Studio 2008\Templates\ItemTemplates”文件夹,在这个文件夹里可以看到自己制作的模板压缩包(.zip文件),将它们复制; 2. 再进入“... [More]