http://support.microsoft.com/kb/910442, this is Chinese, machine translation, not easy to read, English is: http://support.microsoft.com/kb/910442/en-us.
Record several points:
- What is WEB resource? Solve what problem? WEB Resource uses a handler called Webresouce.axd (Hanlder), which is used to retrieve the extracted (retrieve) static resource file from the assembly and return it to the browser. The type of handler WebResource.axd is Assemblyresourceloader.
- How does Web Resource solve these problems (how Web Resource works for Web Resource work)? Which is how the Web resource retrieves the static files from the assembly and returns them to the client based on the request. There are two questions (1) about how the request for Webresouce.axd is generated, and (2) What is the process WebResource.axd handling the request? For the previous question (2) (the answer to question (1) is shown in the 4th below), the answer is as follows:When a request comes on from the client for WebResource.axd, the handler looks for the Web Resource identifier in the< /c0>QueryStringmethod of theRequestobject (when a request for WebResource.axd comes in from the client, the WebResource.axd handler looks for the Web Resource identifier from the QueryString method of the request). Based on the value of the Web Resource identifier, the handler then tries to load the assembly that contains this Resource (Then, WebResource.axd tries to load the assembly that contains the resource that the Web Resource identifier refers to). If This operation is successful, the handler would then look for the assembly attribute and load the resource stream from T He assembly. Finally, the handler would grab the data from the resource stream and send it to the client together with the content type That's 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 has been any changes to the R Esource.
- How do I embed a static resource file in assembly?
- How do I remove a static resource file from assembly (that is, how to generate a request for handler WebResource.axd)?for getting the Web Resource, I had used theGetWebResourceUrlmethod, which is a method of theClientScriptManagerclass that's typically used for managing client-side scripts. This method returns a URL reference to the Server-side resource, which is embedded on an assembly. theGetWebResourceUrlmethod accepts the following and the parameters:
- type: The type of the Server-side resource
- Resource name: The name of the Server-side Resource
to use this method, first you has to create an instance of theClientScriptManagerclass and get the type of the class as shown below.When you have a instance of this class, you then have a to call this method and pass the appropriate parameters as show n below, where I create aHyperLinkbutton, and set theNavigateURLmethod to a embedded HTML resource. 1HyperLink Hlhelpfile =NewHyperLink ();2Hlhelpfile.navigateurl = cs. GetWebResourceUrl (Rstype,"SimpleControl.Help.htm");3HLHELPFILE.ATTRIBUTES.ADD ("onmouseover","changeimage (' image1 ', ' Red ')");4HLHELPFILE.ATTRIBUTES.ADD ("onmouseout","rollbackimage (' image1 ', ' Green ')");5 6 This. Controls.Add (hlhelpfile);7 8Image imgtest =NewImage ();9Imgtest.imageurl = cs. GetWebResourceUrl (Rstype,"SimpleControl.smallFail.gif");TenImgtest.id ="Image1"; OneHLHELPFILE.CONTROLS.ADD (imgtest);
Back to the top 1 question, what does Web resouce solve? The problem with returning a resource file for the client is resolved, so if you know the location of the resource file (that is, if the resource file you requested is no longer assembly), then you do not need to use the Web Resource.