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. Struts2 回顾总结

    1.第一个Struts2入门案例 1.找jar包 Struts2-core xwork-core ognl javasist freemarker commons-lang commons-io co ...

  2. dp表模型-如何写出for循环动态规划

    题目很肤浅.. 但是这件事我们要做.. 那么有一种方法叫做刷表法.. 当你发现这个问题具有最优子结构,重叠子问题时 那么这是一个dp问题是使用本方法的前提 画出该dp状态所对应的矩阵 画出转移关系线. ...

  3. [原创]Centos7 内部常用软件升级计划

    GCC 当前系统版本 gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)

  4. 【转】有关Oracle随机字符串的生成方法及具体应用

    Oracle生成随机字符串的方法是通过dbms_random.string实现的. 1.dbms_random.string用法Oracle官方文档参考链接:http://download.oracl ...

  5. 李洪强iOS经典面试题147-WebView与JS交互

    李洪强iOS经典面试题147-WebView与JS交互   WebView与JS交互 iOS中调用HTML 1. 加载网页 NSURL *url = [[NSBundle mainBundle] UR ...

  6. 序列流 SequenceInputStream

    SequenceInputStream:序列流,对多个流进行合并. SequenceInputStream 表示其他输入流的逻辑串联.它从输入流的有序集合开始,并从第一个输入流开始读取,直到到达文件末 ...

  7. FK JavaScript之:ArcGIS JavaScript API之地图动画

    地图要素动画应用场景:动态显示地图上的要素的属性随着时间的改变而改变,并根据其属性的变化设置其渲染.比如:某水域项目中,随着时间的变化,动态展现水域的清淤进度 本文目的:对ArcGIS JavaScr ...

  8. 使用File查询出所有的文件和目录的信息

    public class Test34 { public static void main(String[] args) { File f=new File("f:"); File ...

  9. WPF整理--动态绑定到Logical Resource

    “What happens if we replace aspecific resource? Would that be reflected in all objects using the res ...

  10. 20145205 《Java程序设计》第8周学习总结

    教材学习内容总结 第十五章 通用API 15.1 日志 日志API简介 java.util.logging包提供了日志功能相关类与接口,不必额外配置日志组件,就可在标准Java平台使用是其好处.使用日 ...