Camillia
asked on
Path to one image works but to the other doesn't
I wonder if this is because of IIS and how the site is setup
1. My coworker set up an IIS site like this
2. You see there's a path assets-->pages-->img-->log in the images in this path aren't showing up. I've tried
/assets/pages/img/login/bg1 .jpg,
../assets/pages/img/login/bg1 .jpg
~/assets/pages/img/login/bg1 .jpg
3. Images under this folder show up "img". This is in the root folder of that "Demo" site. In the image above, I've marked the folder with XX. I have it like this ~/img/CSI-logo.png
When I look at Chrome's console, that path is translated to this (has "demo" in the beginning of it)
4. If I hard code the "demo" root folder, then the image shows up /Demo/assets/pages/img/login/bg1 .jpg
Why is this? I don't want to hardcode /Demo/ How can I fix this? what path do I need to use?
1. My coworker set up an IIS site like this
2. You see there's a path assets-->pages-->img-->log
/assets/pages/img/login/bg1
../assets/pages/img/login/bg1
~/assets/pages/img/login/bg1
3. Images under this folder show up "img". This is in the root folder of that "Demo" site. In the image above, I've marked the folder with XX. I have it like this ~/img/CSI-logo.png
When I look at Chrome's console, that path is translated to this (has "demo" in the beginning of it)
4. If I hard code the "demo" root folder, then the image shows up /Demo/assets/pages/img/login/bg1
Why is this? I don't want to hardcode /Demo/ How can I fix this? what path do I need to use?
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will soon. It's a simple project. I'll upload it. There's no database behind it.
ASKER
I uploaded the code here
https://drive.google.com/drive/folders/1EzoyYPCZ8aBT8QWUtwkQoJIufuEaOHAb?usp=sharing
It's an empty MVC code I created and has 2 pages. Login and the main page. It's the images on the main page and one image inside that don't show up. It's VS2017. The images show up locally when I run the code in VS.
My manager says maybe it's because we're hosting other sites but don't think so. Here's the IIS structure
https://drive.google.com/drive/folders/1EzoyYPCZ8aBT8QWUtwkQoJIufuEaOHAb?usp=sharing
It's an empty MVC code I created and has 2 pages. Login and the main page. It's the images on the main page and one image inside that don't show up. It's VS2017. The images show up locally when I run the code in VS.
My manager says maybe it's because we're hosting other sites but don't think so. Here's the IIS structure
ASKER
I renamed the "asset" folder as "assets1" but that didn't fix it either.
Maybe my manager is right...maybe this is happening because this site's folder is not in it's separate folder. Maybe some other project in this folder is conflicting. This is how my coworker set it up. Screenshot below.
I can just move it under "img" folder since I know that works but would be good to know why this happening...for my own understanding
@it_sage You asked if there are other webconfigs. In the screenshot above, I see another webconfig and this is in it
Maybe my manager is right...maybe this is happening because this site's folder is not in it's separate folder. Maybe some other project in this folder is conflicting. This is how my coworker set it up. Screenshot below.
I can just move it under "img" folder since I know that works but would be good to know why this happening...for my own understanding
@it_sage You asked if there are other webconfigs. In the screenshot above, I see another webconfig and this is in it
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.htm" />
<add value="index.html" />
<add value="default.html" />
<add value="default.aspx" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="iisstart.htm" />
</files>
</defaultDocument>
</system.webServer>
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" />
</authentication>
<identity impersonate="false" />
</system.web>
</configuration>
ASKER
I moved the entire "assets" folder under "img" folder and that didn't work either. The paths have to have /Demo/ in the beginning of them. Don't know why.
This link https://weblogs.asp.net/fmarguerie/avoiding-problems-with-relative-and-absolute-urls-in-asp-net
to use <%=Request.ApplicationPath %>
but how would do I it in JavaScript? the path is in login-5.min.js too
This link https://weblogs.asp.net/fmarguerie/avoiding-problems-with-relative-and-absolute-urls-in-asp-net
to use <%=Request.ApplicationPath
but how would do I it in JavaScript? the path is in login-5.min.js too
ASKER
This worked but I'll open a new question. I want to know why this worked
~/../assets
~/../assets
-saige-