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. Socket 类通信例子-第24章

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  2. STL set 用法

      c++ stl集合set介绍 c++ stl集合(Set)是一种包含已排序对象的关联容器.set/multiset会根据待定的排序准则,自动将元素排序.两者不同在于前者不允许元素重复,而后者允许. ...

  3. iOS 消息推送(APNs) 傻瓜式教程

    也可以去我的简书页面查看这篇文章 首先: 1.做iOS消息推送需要真机测试 2.做iOS消息推送需要有付费的开发者账号 是否继续看帖? 先学习一下相关的知识吧! 因为中途可能会遇到一些问题,这篇文章或 ...

  4. Wpf/Wp/Silverlight-Chart图表控件:柱状图、饼状图等使用汇总

    链接:http://www.cnblogs.com/jimson/archive/2010/06/21/Wpfchat.html http://www.cnblogs.com/mgen/p/32361 ...

  5. JDBC连接数据库(数据源的方式)

    在tomcat安装目录下的context.xml文件中配置DataSource <Resource name="jdbc/news"(JNDI的名字,news是数据库的实例名 ...

  6. BFC给我的帮助以及对hasLayout的认识

    布局的时候经常想让一个或几个元素并并排的放在一起,有时给其中的一个浮动,元素是在一行了,可还是都左边重叠了,总是这样那样改来改去,小白的我也是醉了! 今天偶然间看到了了BFC这个东东,虽然现在还是不是 ...

  7. 使用 yum 安装 virtualbox 虚拟机

    我的环境是centos7,所以也可以说是在centos7下使用yum安装virtualbox,不过对于其他的LINUX发行版方法都一样. 下面的操作都是在命令行中进行的. 1.首先需要配置yum的源. ...

  8. Django入门2

    Django模板简单实例 上篇中将html写在了views中,这种混合方式(指Template和views混在一起)不适合大型开发,而且代码不易管理和维护,下面就用Django自带的模板来学习(显示一 ...

  9. Unity3d使用UGUI实现长按功能

    UGUI的Button组件只有OnClick事件的监听,要实现长按功能,要监听按下事件和抬起事件,所以要使用到EventTrigger组件中的OnPointerDown和OnPointerUp来监听. ...

  10. Learn ZYNC (5)

    今天为了熟悉axiLite的自定义ip核设计, 把LED和SW的往AXI总线输入输出定义在一个ip核中, BD设计如下: ip核顶层文件(增加了LED_Out和SW_In的定义)mygpio_v1.0 ...