Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

webresource not working in asp.net 2.0 beta

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jojobar - 27 Oct 2005 00:38 GMT
Okay, I am trying to do is to test the webresource in 2.0

1. I created a new project with assembly name (and default assembly name)
"Office".

2. I added the following to the AssemblyInfo.cs file (present under the
Properties folder of the project)
[assembly: System.Web.UI.WebResource("Office.test.js",
"application/x-javascript")]

3. Now I created a file called test.js on the root folder of the project,
having only a single line as:

alert(2);

4. I then marked the test.js file as embedded resource.

5. Now in a file called login.aspx (at the root) I added the following,

<script runat="server">
   protected void Page_PreRender(object o, EventArgs e)
   {
      string scriptLocation =
this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "Office.test.js");
       this.Page.ClientScript.RegisterClientScriptInclude("TestFunctions",
scriptLocation);
   }
</script>

6. This produces the web resource on the rendered source as:
<script
src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt7LgDQ-rSE3fGRgtkb60&t=632659511657343750" type="text/javascript"></script>

So far so good, but it is not executing the javascript. To test everything
is okay, I changed the script location (hardcoded) in login.aspx to:
string scriptLocation = "/newoc/test.js"; // where newoc is my virtual
directory.

Now the alert gets shown when the page is rendered (as it should). It is not
getting it from webresource.

What I am doing wrong? any pointer will be of great help.

Thanks

Signature

-jojobar

Steven Cheng[MSFT] - 27 Oct 2005 08:40 GMT
Hi Jojobar,

Welcome again.
As for the embeded webresource, from the code and the steps you provided,
all seems good. I think we can check from the following steps:

1. first use ildasm tool to check the compiled class library assembly so as
to confirm the image file is correctly embeded.

2. Then, since the web page will contains the dynamic resource's url like:

<script
src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt
7LgDQ-rSE3fGRgtkb60&t=632659511657343750" type="text/javascript"></script>

you can directly pick up the  "src" attribute's value and paste in the IE
browser to see whether the content can displayed.

BTW, for class library project, we can put  the
[assembly:System.Web.UI.WebResource(

attribute in any source file(which will be compiled into the class liblrary
assembly) in the project , not forced to be put in
AssemlyInfo.cs file.

Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: webresource not working in asp.net 2.0 beta
| thread-index: AcXahlCZ47P21P4tRHSpOlb9X4Y73w==
[quoted text clipped - 17 lines]
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134152
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
[quoted text clipped - 29 lines]
| 6. This produces the web resource on the rendered source as:
| <script

src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt
7LgDQ-rSE3fGRgtkb60&t=632659511657343750" type="text/javascript"></script>

| So far so good, but it is not executing the javascript. To test everything
| is okay, I changed the script location (hardcoded) in login.aspx to:
[quoted text clipped - 7 lines]
|
| Thanks
jojobar - 27 Oct 2005 14:30 GMT
I checked in ildasm and it seems to be there. Also to test it I had put a lot
of just comment in the resource file and the assembly size increased.

However when I paste the src on the browser like:

http://localhost/newoc/WebResource.axd?d=4dJysf0CLuFO5XdguWCxA8dHL68G94YWJYPe-ApY9HOLr7s-ev4wQIcPmmwIf8Yk0&t=632660016096250000

It said that the WebResource.axd could not be found. Maybe some iis settings
needs to be done.

However, when I see the source of my aspx file (from the browser), it shows
many such webresource.axd entries and all the other ones work!
Signature

-jojobar

> Hi Jojobar,
>
[quoted text clipped - 105 lines]
> |
> | Thanks
jojobar - 27 Oct 2005 14:33 GMT
Another thing,

When I paste another webresource.axd on the browser (that microsoft
produced), it is not giving any error!
Signature

-jojobar

> Hi Jojobar,
>
[quoted text clipped - 105 lines]
> |
> | Thanks
jojobar - 27 Oct 2005 14:48 GMT
Yet another thing...

any ideas where to look for in ildasm if the resource is embedded? I looked
at the manifest and found it, but I cannot see the content.  I know that it
is in there because the assembly size has roughly increased equivalent to the
number of bytes in the resource file.

Thanks again
Signature

-jojobar

> Hi Jojobar,
>
[quoted text clipped - 105 lines]
> |
> | Thanks
Steven Cheng[MSFT] - 28 Oct 2005 03:34 GMT
Hi Jojobar,

Seems strange, have you tried creating a new project to see whether the
problem remains? It is likely a environment specific problem. Also, as for
the ILDASM, we can only see the resource's name and address (offset....)
from the Manifest section, the content can not be displayed since they've
been stored as binary image in assembly.  Also, have you tried other kind
of resource like  gif/jpeg pictures  to see whether they can be retrieved
correctly?

Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: webresource not working in asp.net 2.0 beta
| thread-index: AcXa/Q3mtLA2ZOBzR5OWNLCfkfo9Jg==
| X-WBNR-Posting-Host: 66.32.181.251
| From: "=?Utf-8?B?am9qb2Jhcg==?=" <jojobar@nospam.nospam>
| References:  <7F439162-316F-473F-A081-3FC1779280B7@microsoft.com>
<2V5XIns2FHA.2904@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: webresource not working in asp.net 2.0 beta
| Date: Thu, 27 Oct 2005 06:48:04 -0700
[quoted text clipped - 13 lines]
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134242
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
[quoted text clipped - 19 lines]
| >
| > <script

src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt
| > 7LgDQ-rSE3fGRgtkb60&t=632659511657343750" type="text/javascript"></script>
| >
[quoted text clipped - 75 lines]
| > | 6. This produces the web resource on the rendered source as:
| > | <script

src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt
| > 7LgDQ-rSE3fGRgtkb60&t=632659511657343750" type="text/javascript"></script>
| > |
[quoted text clipped - 11 lines]
| > |
| > | Thanks
jojobar - 28 Oct 2005 04:10 GMT
Thanks again Steven,

It seems strange to me too! I tried all different things I know about or
have read from the internet. I bet it must be a simple thing I am missing.

I will also try the two things you suggested (try it in a different project
and try on image/gif files) and let you know.

What puzzles me most is that the ms resources are working fine. So, I think
somewhere I am making a mistake in defining the webresources or calling them!

Regards
jojobar
Signature

-jojobar

> Hi Jojobar,
>
[quoted text clipped - 178 lines]
> | > |
> | > | Thanks
Steven Cheng[MSFT] - 28 Oct 2005 07:22 GMT
Thanks for the response.

OK. If there're any new updates or anything else need assistance, please
feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: webresource not working in asp.net 2.0 beta
| thread-index: AcXbbRYP1G+6pmb2SCma4n2I1W798Q==
| X-WBNR-Posting-Host: 24.30.72.206
| From: "=?Utf-8?B?am9qb2Jhcg==?=" <jojobar@nospam.nospam>
| References:  <7F439162-316F-473F-A081-3FC1779280B7@microsoft.com>
<2V5XIns2FHA.2904@TK2MSFTNGXA01.phx.gbl>
<07E375CD-3E22-4459-AD84-2CFBA26BDA84@microsoft.com>
<qeNJqg22FHA.2904@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: webresource not working in asp.net 2.0 beta
| Date: Thu, 27 Oct 2005 20:10:02 -0700
[quoted text clipped - 13 lines]
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:134451
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
[quoted text clipped - 85 lines]
| > | >
| > | > <script

src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt
| > | > 7LgDQ-rSE3fGRgtkb60&t=632659511657343750"
| > type="text/javascript"></script>
[quoted text clipped - 83 lines]
| > | > | 6. This produces the web resource on the rendered source as:
| > | > | <script

src="/newoc/WebResource.axd?d=AC-tFcC2LfSlk9Gh_o5X4d1EVF57Jgee8Vh-uzb05tRBlt
| > | > 7LgDQ-rSE3fGRgtkb60&t=632659511657343750"
| > type="text/javascript"></script>
[quoted text clipped - 14 lines]
| > | > |
| > | > | Thanks
andyhink - 20 Dec 2007 15:32 GMT
I'm having this same exact issue.  Any chance this was resolved?  Thanks
Andy

> Thanks for the response.
>
[quoted text clipped - 253 lines]
> | > | > |
> | > | > | Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.