Last post Nov 20, 2009 05:11 PM by jayamaruthyraman_jaganathan
Aug 25, 2006 08:27 PM|jeffkretz|LINK
This is my first time in dealing with embedded resources, so I'm sure I'm just doing something wrong.
Then, to ensure I would name the resource correctly, I used the:
Assembly.GetManifestResourceNames() to get the precise resource names in the file.
So I added this attribute to the AssemblyInfo.cs:
And my page uses this code:
throw new Exception("The resource could not be found.");
The page renders the include as:
If I type the url in directly:
I get a 404 "The resource cannot be found error".
If I trap the application error, I get a "This is an invalid webresource request." error.
Does anyone have some advice for what I may be doing wrong?
Aug 28, 2006 01:49 AM|jeffkretz|LINK
Well, for what its worth, the problem went away when I did two things:
1. I moved the AssemblyInfo.cs into the "Properties" folder (probably completely insignificant, but I thought I'd mention it).
2. I changed the GetWebResourceUrl command. It was pulling a type from the current page instance: this.GetType(). I changed this to read:
The "BasePage" class is in the same assembly as the resource, whereas "this" refers to the inherited page that was NOT in the same assembly. Perhaps this is necessary?
Suddenly everything was working.
Aug 30, 2006 12:41 AM|joshmccullough|LINK
Sep 23, 2006 07:04 AM|doormalena|LINK
Better use typeof(Global) where Global is the class inside Global.asax.cs which inherrits HttpApplication. This class is always inside the same assembly as AssemblyInfo.cs is applied to (where the resources are defined)
Feb 28, 2008 04:01 AM|stelianx|LINK
Hello to everybody.
I run the same issue from 1 day. The explanation is very simple.
When We are inside a user control, this.Page.GetType().Equals(typeof(YourNamespace.YourPageClass)) == false.
This because when a page is run in ASP.NET, a new type wich INHERITS the YourNamespace.YourPageClass is created.
What you must do to work 4 sure is to use this.Page.GetType().BaseType. It works
Sep 16, 2009 07:45 AM|anjenkin84|LINK
Hey everyone, have just spent a couple of hours trying to also get this working.
My scenario was similar to this, trying to add script resource from within a user control. My user control was in a different namespace to the comsuming webpage.
The only way I could get this to work was by specifying "this.GetType().BaseType" as the type parameter for Page.ClientScript.GetWebResourceUrl.
Hope this is usefull for other people experiencing the same problem.
Nov 20, 2009 05:11 PM|jayamaruthyraman_jaganathan|LINK
Thanks to one of the earlier posters.
I resolved my issue using 'BaseType' approach.