Insert spark variable to create string

Hi, new to fix, so it should be simple.

I am converting an old webfoms page to mvc using a spark. I want to use Base.Application to create src url

original markup

<img alt="" src="<%= Base.ApplicationPath %>images/screenshots/myImage.jpg" />

I tried it in sparks

<img alt= src=${  Base.ApplicationPath }+">images/screenshots/myImage.jpg" />

but not joy.

How can I make it into sparks?

+3
source share
2 answers

I'm not sure you know about this, but Spark has a DefaultResourcePathManager that will automatically locate the root of the site if you prefix the resource with a tilde, so this should work fine and looks more neat.

<img alt="" src="~/images/screenshots/myImage.jpg" />

... ! , , , (CDN) - Spark Module.dll, dll .

, CDN, , , Spark:

<resources>
  <add match="/content/images" location="http://mycdn.com/youraccount/images"/>
  <add match="/content/css" location="http://mycdn.com/youraccount/css"/>
  <add match="/content/js" location="http://mycdn.com/youraccount/js"/>
</resources>

... . .

+2

.

<img alt="" src="${Base.ApplicationPath}images/screenshots/myImage.jpg" />
+1

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


All Articles