http://support.microsoft.com/kb/910442,这是中文的,机器翻译的,不太容易看懂,英文的是:http://support.microsoft.com/kb/910442/en-us。

记录几个要点:

  1. Web Resource是什么?解决什么问题?Web Resource使用一种称为WebResouce.axd的处理程序(Hanlder),该处理程序用来从Assembly中检索抽取(retrieve)静态资源文件并返回给浏览器。处理程序WebResource.axd的类型是AssemblyResourceLoader。
  2. Web Resource是怎样解决这些问题的(Web Resource是如何工作的How Web Resource Work)?也就是Web Resource是怎样根据请求从Assembly中检索抽取静态文件并返回给客户端的(分解开来,这里有两个个问题(1)针对WebResouce.axd的请求时如何产生的;(2)处理程序WebResource.axd处理该请求的具体过程是怎样的)?针对前面的问题(2)(问题(1)的答案见下面的第4点),回答如下:When a request comes in from the client for WebResource.axd, the handler looks for the Web Resource identifier in theQueryString method of the Request object(当一个针对WebResource.axd的请求从客户端进来时,WebResource.axd处理程序从该请求的QueryString方法中查找Web Resource identifier). Based on the value of the Web Resource identifier, the handler then tries to load the assembly that contains this resource(然后,WebResource.axd试图加载包含Web Resource identifier所指资源的Assembly). If this operation is successful, the handler will then look for the assembly attribute and load the resource stream from the assembly. Finally, the handler will grab the data from the resource stream and send it to the client together with the content type that you specify in the assembly attribute。The URL for WebResource.axd looks like the following:
    WebResource.axd?d=SbXSD3uTnhYsK4gMD8fL84_mHPC5jJ7lfdnr1_WtsftZiUOZ6IXYG8QCXW86UizF0&t=632768953157700078
    

    The format of this URL is WebResource.axd?d=encrypted identifier&t=time stamp value. The "d" stands for the requested Web Resource. The "t" is the timestamp for the requested assembly, which can help in determining if there have been any changes to the resource.

  3. 如何将静态资源文件嵌入Assembly?
  4. 如何从Assembly中取出静态资源文件(即如何生成对处理程序WebResource.axd的请求)?For getting the Web Resource, I have used the GetWebResourceUrl method, which is a method of the ClientScriptManagerclass that is typically used for managing client-side scripts. This method returns a URL reference to the server-side resource that is embedded in an assembly. The GetWebResourceUrl method accepts the following two parameters:
    • Type: The type of the server-side resource
    • Resource Name: The name of the server-side resource

    To use this method, first you have to create an instance of the ClientScriptManager class and get the type of the class as shown below.When you have an instance of this class, you then have to call this method and pass the appropriate parameters as shown below, where I create a HyperLink button, and set the NavigateURL method to point to an embedded HTML resource.

     HyperLink hlHelpFile = new HyperLink();
    hlHelpFile.NavigateUrl = cs.GetWebResourceUrl(rsType, "SimpleControl.Help.htm");
    hlHelpFile.Attributes.Add("onmouseover", "ChangeImage('image1','Red')");
    hlHelpFile.Attributes.Add("onmouseout", "RollbackImage('image1','Green')"); this.Controls.Add(hlHelpFile); Image imgTest = new Image();
    imgTest.ImageUrl = cs.GetWebResourceUrl(rsType, "SimpleControl.smallFail.gif");
    imgTest.ID = "image1";
    hlHelpFile.Controls.Add(imgTest);

    回到上面1的问题,Web Resouce解决什么问题?解决的是为客户端返回资源文件的问题,所以如果你知道了资源文件的位置(也就是说如果你请求的资源文件不再Assembly中),完全没有必要使用Web Resource。

ASP.Net中的Web Resource的更多相关文章

  1. Asp.net中的web.config配置

    目录 Asp.net中的web.config配置... 1 一. 配置文件保存位置... 2 二. 配置文件加载顺序... 2 三. 配置文件节点介绍... 3 1. . 3 2. . 5 3. . ...

  2. 请解释ASP. NET中的web页面与隐藏类之间的关系

    请解释ASP.NET中的web页面与其隐藏类之间的关系 其实页面与其隐藏类之间就是一个部分类的关系,你在页面上放一个一个的控件就是在这个类中定义一个一个的属性, 因为是同一个类的部分类的关系,所以隐藏 ...

  3. Asp.net中的web.config配置文件(转)

    最近开始学习.NET的开发,首先碰到的就是web.config的配置问题,把网上大虾的资料转发记录一下,以备不时之需. 原贴路径如下:http://blog.csdn.net/hbqhdlc/arti ...

  4. 请解释ASP.NET 中的web 页面与其隐藏类之间的关系?

    一个ASP.NET 页面一般都对应一个隐藏类,一般都在ASP.NET 页面的声明中指定了隐藏类例如一个页面 Tst1.aspx 的页面声明如下 <%@ Page language="c ...

  5. 请解释ASP.NET中的web页面与其隐藏类之间的关系

    其实页面与其隐藏类之间就是一个部分类的关系,你在页面上放一个一个的控件就是在这个类中定义一个一个的属性, 因为是同一个类的部分类的关系,所以隐藏类可以访问到页面上控件,这样做是为了把展现与处理逻辑分开 ...

  6. 关于Idea模块化部署web项目,Web Resource Directories作用

    问题由来:接到某个所谓“将web工程中部分代码抽出打包,但待打包部分代码还需要在现场部署时能做微调”的需求. 解决方法:将待打包部分代码作为一个module,让工程依赖该模块,满足抽离打包与现场可调试 ...

  7. ASP.NET 5系列教程 (六): 在 MVC6 中创建 Web API

    ASP.NET 5.0 的主要目标之一是统一MVC 和 Web API 框架应用. 接下来几篇文章中您会了解以下内容: ASP.NET MVC 6 中创建简单的web API. 如何从空的项目模板中启 ...

  8. ASP.NET MVC4中调用WEB API的四个方法

    http://tech.it168.com/a2012/0606/1357/000001357231_all.shtml [IT168技术]当今的软件开发中,设计软件的服务并将其通过网络对外发布,让各 ...

  9. 返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, .net 4.5 带来的更方便的异步操作

    原文:返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, ...

随机推荐

  1. oracle 安装

    一 : 建议安装在64位机器上,程序下载地址 http://download.oracle.com/otn/nt/oracle11g/112010/win64_11gR2_database_1of2. ...

  2. 【Linux】unzip命令,记一次遇到的问题

    最近在做BOSS系统云平台部署脚本,联调时发现Shell脚本中存在问题,下方记录 某个地方提示是否覆盖 [root@haiwai test]# unzip /home/redis/test/main- ...

  3. 安装并配置前端自动化工具——grunt

    Grunt和所有Grunt插件都是基于nodeJs来运行的,因此在你的电脑上需要安装nodeJs.安装nodeJs非常简单,点击访问nodeJs官网https://nodejs.org,然后nodeJ ...

  4. LinkedList实现队列和堆栈的代码

    package 集合; import java.util.LinkedList; /* *队列:先进先出 *把romovelast改成romoveFirst就成了堆栈 先进后出 *  * */publ ...

  5. Sublime Text 2配置文件详解

    Sublime Text 2是那种让人会一眼就爱上的编辑器,不仅GUI让人眼前一亮,功能更是没的说,拓展性目前来说也完全够用了,网上介绍软件的文章和推荐插件的文章也不少,而且很不错,大家可以去找找自己 ...

  6. Odoo Email Template Problem

    Odoo 8.0 的邮件模板是运行自jiajin2沙盒中的阉割版mako,像自定义及 <%%>等功能都无法正常使用. 且for-loop %for %endfor不能嵌套在table中使用 ...

  7. C++实现vector

    用了双向链表,快排,<<,=,[]重载,还有erase的实现比较好玩 //my Vecter ;T need "operator<" #include <i ...

  8. [转]RMAN检测数据库坏块

    backup validate check logical database; select * from v$database_block_corruption; RMAN> backup v ...

  9. 201301 JAVA题目0-1级

    描述 编写一个函数,传入一个int型数组,返回该数组能否分成两组,使得两组中各元素加起来的和相等,并且,所有5的倍数必须在其中一个组中,所有3的倍数在另一个组中(不包括5的倍数),能满足以上条件,返回 ...

  10. ouath原理

    1.OAuth的简述 OAuth(Open Authorization,开放授权)是为用户资源的授权定义了一个安全.开放及简单的标准,第三方无需知道用户的账号及密码,就可获取到用户的授权信息,并且这是 ...