Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebResource.axd

I have 2 pages in ASP.Net

The first page has some .Net controls and therefore renders out the javascript includes for WebResource.axd

The other page does not render any .Net controls and has some custom javascript that generates some html. This includes validators and other .Net controls as the WebResource.axd was not rendered initially and there has been no postback I am having problems submits validators etc.

The question is how does IIS or .Net work out that it needs to generate the WebResource.axd so I can make my new page render this even though initially .Net does not think it is needed.

like image 420
Jules Avatar asked Jan 18 '12 14:01

Jules


2 Answers

The WebResource.axd gets added to your pages that contain .Net controls with embedded resources. So, if you have a page that has no controls with embedded resources, i.e.- just standard HTML, you will not see WebResource file.

Here's a good blog on how it works: http://scottonwriting.net/sowblog/archive/2010/10/28/just-where-is-webresource-axd.aspx

like image 132
Kyle Savage Avatar answered Oct 02 '22 16:10

Kyle Savage


Includes of the WebResource.axd will be added by the controls (who need it) itself. They will not be added by IIS or the underlying ASP.NET framework.

So for example if a control has a dependency on a embedded webresource it will do something like this:

string scriptUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "RESOURCE_NAME.js")

Page.ClientScript.RegisterClientScriptInclude("RESOURCE_NAME.js", scriptUrl);

It looks like you created a dependency on a web resource which doesn't get included because you didn't ask for it. It works on the first page only because of the fact the other control on your first page also need it.

So before you can continue you need to know which web resource you need and then include it yourself. The only problem I have with this solution is that you are using a web resource which is not in your control. So if you can write it yourself.

like image 28
Martijn B Avatar answered Oct 02 '22 14:10

Martijn B