ASP.NET How much does it cost to repeatedly call an application variable?

In short: is it worth checking the application variable, for example Application ("WebAppName"), 10-20 times every time the page loads?

Background: (feel free to criticize)

Some of them on my site contain many links and images that cannot use relative URLs due to their inclusion in different paths.

Therefore, they include frequent instances.

<img src="<%=Application("Webroot")%>images\image.gif">

Is accessing an application variable so expensive?

Should I just put the value of Application in some local variable where needed?

IMPORTANT NOTE:

I need my webapp to work fine on the server, either on the root network ("/") or on the virtual website ("/ app").

.

+3
5

- , - . - , ( - ), .

, , , , . 10 000 , . , concurrency, - ?

+4

:

<img src="<%=VirtualPathUtility.ToAbsolute("~/images/image.gif")%>"

MVC, , ..

<%=Html.Image("~/images/image.gif")%>
+4

Application , ReadWriteObjectLock ( , ), , , , -, , - , , . , , .

+2

Request.ApplicationPath ( IIS)

0

The short answer is to measure it and decide on your own environment. I would say that it does not matter.

The longer answer is that you should have a call wrapped up in something anyway ... Like WebConfiguration.Root. This will give you the opportunity to do any optimization at any time in the future.

0
source

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


All Articles