WebResource.axd

I have 2 pages in ASP.Net

The first page has some .Net controls and therefore displays javascript for WebResource.axd

Another page does not display any .Net controls and has some custom javascript that generates some html. This includes validators and other .Net controls, since WebResource.axd was not originally native, and there was no postback. I'm having problems sending validators, etc.

The question is how IIS or .Net work to create WebResource.axd, so I can make my new page render even if .Net doesnโ€™t think it is necessary at first.

+6
source share
2 answers

WebResource.axd is added to your pages containing .Net elements with embedded resources. So, if you have a page that does not have controls with embedded resources, i.e. With standard HTML only, you will not see the WebResource file.

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

+4
source

The inclusion of WebResource.axd will be added by the controls (who needs it). They will not be added by IIS or the underlying ASP.NET framework.

So, for example, if the control has a dependency on the built-in 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 that doesn't turn on because you didn't ask for it. It only works on the first page because another control on the first page also needs it.

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

+1
source

Source: https://habr.com/ru/post/906311/


All Articles