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
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