468,719 Members | 1,787 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,719 developers. It's quick & easy.

WebResourceAttribute: cannot get a valid web resource url!

coz
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("Assemb lyWithWebResources.help.htm");
return s.ReadToEnd();
************************************//
From my webpage, I use the following to get a web resource url:

//************************************
Page.ClientScript.GetWebResourceUrl(typeof(Assembl yWithWebResources.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
Jan 1 '06 #1
1 2066
coz
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" wrote:
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("Assemb lyWithWebResources.help.htm");
return s.ReadToEnd();
************************************//
From my webpage, I use the following to get a web resource url:

//************************************
Page.ClientScript.GetWebResourceUrl(typeof(Assembl yWithWebResources.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

Jan 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by WWengert | last post: by
2 posts views Thread by Amelyan | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Oskars | last post: by
9 posts views Thread by bryonone | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.