Iam new to ASP.NET and poking around my first ASP Web Application projects in .NET 4.0
I have problem, which I can’t solve, and google searches does not bring any joy.
So I would kindly ask for help and/or explanation of following problem:
Assume that I have set up following project structure:
\default.aspx
\[gfx] (dir)
\[images]
\picture.jpg
\[css]
\stylesheet.css
\[js]
\jquery.js
\[backend]
\main.aspx
So, in default.aspx I can link to image or css like that:
< img src="/gfx/images/picture.jpg">
< link rel="stylesheet" type="text/css" href="/gfx/css/stylesheet.css"/>
It works, but Iam afraid that this linking technique is not the “correct” one. Yes – it works and it links, but as I was PHP developer I was always linking to the full path of resource, for ex:
< img src=”gfx/images/picture.jpg” />
Which was translated to
< img src=”http://www.mysite.com/gfx/images/picture.jpg” />
Is there a way to achieve similar result in ASP.NET without loosing the design preview in visual studio ? It my linking technique is common one or is there another way ?
Best regards
Mostly
~operator is used, the asp.net automatically maps it to the root of your application.you can also use application root path in variable and can use. For Example
The use of later technique has a few advantages, as it is rendered as absolute path (little bit fast)
and configurable in a sense if you want to place static content from different server.