WebResourceAttribute: cannot get a valid web resource url!

G

Guest

Someone please help! I cannot for the life of me get a web resource in
asp.net 2.0 to return any content.

I know I have correctly embedded my resources (because I can manually get
the resources from my assemblies at runtime.)

The URLs I get back are valid (they throw no errors) but they return zero
content. I get a broken page from text/html resources and broken images, etc.
I can get an error if I use an invalid resource name, so I know my resource
names are correct when I get no error.

I have boiled a project down to nothing but an Assembly with
EmbeddedResources and WebResourceAttributes declared, a webpage that gets a
URL for each exposed resource, and even an NUnitASP project to test the
results. I get no content no matter what I do:

I have two resources, a simple html page and an image. My assembly looks
like tihs:

//************************************
[assembly: WebResource("image1.jpg", "image/jpeg")]
[assembly: WebResource("help.htm", "text/html", PerformSubstitution = true)]
namespace AssemblyWithWebResources
{
public class EmptyClass { }
}
************************************//


When compiled, I am able to successfully extract the resources so I know
they are embedded correctly:


//************************************
System.IO.Stream s =
resourceAssembly.GetManifestResourceStream("AssemblyWithWebResources.help.htm");
return s.ReadToEnd();
************************************//


From my webpage, I use the following to get a web resource url:

//************************************
Page.ClientScript.GetWebResourceUrl(typeof(AssemblyWithWebResources.EmptyClass), "help.htm");
************************************//

This returns valid URLs that dont cause any errors, but also return no data.
I have been through every posting i can find online and nothing gets me past
this problem. Can someone please tell me what I am doing wrong? I know it
isn't a namespace issue (you used to have to append the namespace before the
resource name) because that does cause an error from the generated URL.

I have posted my solution online, if someone would please download it and
kick it around:

http://fluidnature.com/test/TestOfWebResources.zip

Thank you,

f
 
G

Guest

I have re-posted my zip file, after removing the NUnitAsp project and
dependencies because you might not have it installed and its not required to
see the problem. I also I fixed the solution file reference to the website
directory.

Now all you need is VS2005. Extract the contents, open the solution and run
it:

http://fluidnature.com/test/TestOfWebResources.zip

Please, somebody look at this project and tell me what I did wrong embedding
the included resources and exposing them via GetWebResourceUrl? I have found
several other people having this same problem, so it would definately provide
benefit to the community.

Thank you very much,

coz

coz said:
Someone please help! I cannot for the life of me get a web resource in
asp.net 2.0 to return any content.

I know I have correctly embedded my resources (because I can manually get
the resources from my assemblies at runtime.)

The URLs I get back are valid (they throw no errors) but they return zero
content. I get a broken page from text/html resources and broken images, etc.
I can get an error if I use an invalid resource name, so I know my resource
names are correct when I get no error.

I have boiled a project down to nothing but an Assembly with
EmbeddedResources and WebResourceAttributes declared, a webpage that gets a
URL for each exposed resource, and even an NUnitASP project to test the
results. I get no content no matter what I do:

I have two resources, a simple html page and an image. My assembly looks
like tihs:

//************************************
[assembly: WebResource("image1.jpg", "image/jpeg")]
[assembly: WebResource("help.htm", "text/html", PerformSubstitution = true)]
namespace AssemblyWithWebResources
{
public class EmptyClass { }
}
************************************//


When compiled, I am able to successfully extract the resources so I know
they are embedded correctly:


//************************************
System.IO.Stream s =
resourceAssembly.GetManifestResourceStream("AssemblyWithWebResources.help.htm");
return s.ReadToEnd();
************************************//


From my webpage, I use the following to get a web resource url:

//************************************
Page.ClientScript.GetWebResourceUrl(typeof(AssemblyWithWebResources.EmptyClass), "help.htm");
************************************//

This returns valid URLs that dont cause any errors, but also return no data.
I have been through every posting i can find online and nothing gets me past
this problem. Can someone please tell me what I am doing wrong? I know it
isn't a namespace issue (you used to have to append the namespace before the
resource name) because that does cause an error from the generated URL.

I have posted my solution online, if someone would please download it and
kick it around:

http://fluidnature.com/test/TestOfWebResources.zip

Thank you,

f
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top