IIS not loading css file outside of website folder - html

I have an ASP 4.0 web site being served by IIS 8 that is in a folder outside of wwwroot. The site will load, but a css file that I am using is not being loaded (getting a 404 error).
Here's the folder path for the site:
C:/Sites/Test/"website I am using"
And the folder path for the css file:
C:/Sites/Test/sharedfiles/css/stylesheet.css
Here's the link I am using to connect to the css file (with spaces to get this to post)
< link href="~/../sharedfiles/css/stylesheet.css" rel="stylesheet" type="text/css" / >
This should load the css file, but it does not. I'd like to figure out how to get this working.
The Sites folder is shared for IIS_IUSRS and IUSR and permissions are passed down to the folders below, including the Test/sharedfiles/css folder.
The web site folder is what's selected by IIS for the website. I have Anonymous Authentication enabled for Application Pool identity and Static File serving is enabled.
I'd appreciate any other ideas on how to figure out the problem!

Make sharedfiles a virtual directory and establish a web site or a web application there and access your resources (css etc.) using a url. So in local host you would have http://localhost/sharedfiles/yourcss.css
Thats the correct way to do it - what you are trying to implement here is your own CDN.

Related

Showing a link to a folder on website hosted on raspberry pi

I'm trying to host a website on a Raspberry pi4. I'm having some problems displaying the folder.
The code below is what I have so far, but, the following error message appears when I press the link: The requested URL was not found on this server.
<title> Folder </title>
</head>
<body>
<h1>Folder</h1>
<a href ="\home\pi\Documents" > Click to open folder </a>
</body>
</html>```
There are two obvious problems here:
Path separators in UNIX/UNIX-like operating systems (including Linux) and in URLs are /, not \.
URLs need to be provided by an HTTP server (such as Apache HTTPD, Nginx, or Lighttpd). In a traditional configuration (designed to just serve up static files) the root of the website will map on to a specific directory on the file system, and not the root of the file system (which would expose all sorts of private files).
The path you need to ask for needs to treat / as the server's root directory and not the file system's root directory.

I can't open local Folder from link on Sharepoint website

i need help : i can't open local folder from hyperlink in webPart 'Script Editor'
Simple Code : [a href='C:\Users\User\Desktop\Folder']open folder[/a]
or like a link in Library. Any idea?
weird things that is working on the another PC and not on mine.
I'am working with IE 11
If you are working on the server this will work but for users that are not, the path will try to get the folder on their local machine. You might try to have a website in your IIS and put files in a folder of a website. Then you might be able to link the folder (with URL (http or https), not by path) if the 'directory browsing' is enabled in your iis features.
You can find more info on directory browsing here: http://blogs.iis.net/bills/how-to-enable-directory-browsing-with-iis7-web-config
PS: this is not a SharePoint question...

For PyCharm/WebStorm my IDE's local server is not detecting other directories

When I select a html file to open "in browser" in Webstorm it works and it opens under the localhost. The issue I'm having is that this webstorm internal server is not detecting any of the other paths in my project root like images and javascript files.
I should note that this feature has worked before on other projects I started from scratch using "new project." The difference with this project is that I opened a directory as a project.
The built-in webserver serves files from http://localhost:<built-in server port>/<project root>. Forward slashes in URLs tell the browser to resolve them relative to the web server root (localhost:63342 in your case), causing 404 errors.
If you like to change the default web path on built-in web server, you have to re-configure the server by editing your system hosts file accordingly - see http://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559.

link file extension correction

I was just crafting some html for a webpage on a local server on my mac. I added a link to a stylesheet stored on my local server, but forgot to add the ".css" file extension in the href attribute. I didn't realize my mistake until I uploaded my files to an externally hosted server--because somehow the stylesheet could be found without the extension on my local server, whereas when I tried to load the page from the external server the extension was not assumed and my styles didn't load.
What entity figured out my error and corrected it locally, and why wasn't my error corrected when the page was hosted externally?
It could be that your local web server is serving the file up as text/css and the external one is not. What happens if you use TYPE="text/css" inside your LINK tag to the CSS file? That should force it to interpret the linked file as text/css.

Aptana Studio 3 preview problems with absolute path

I have this structure for my project:
Root Directory
|-css folder
|-style.css
|
|-it folder
|-index.html
If I try to include css file with:
<link href="/css/style.css" rel="stylesheet" type="text/css"/>
from index.html, aptana preview and also internal server can not find style.css.
Why is this?
In my remote server it works perfectly and I do not want to use a relative path.
In terms of the "why", the problem you are having is related to how your development server is setup versus your production server.
Assuming a standard setup, your production server will receive requests for a domain (i.e., http://mysite.com) that is, for lack of a better word, mapped to a folder on your server (i.e, a request to http://mysite.com will be mapped to a folder, /var/www/mysite, on your server).
So, when you link to a style sheet with /css/style.css, your (production) sever immediately goes to the /var/www/mysite folder and starts looking for the css folder, file and so on. No problems with that, as you point out.
Your development machine, however, is serving up pages locally and has a different directory structure for mapping to files and folders.
When I open an HTML page in my Aptana project and hit the preview button, Studio loads http://127.0.0.1:8020/mysite/public/404.html (note how the first folder after the IP and port is mysite). To load the absolutely pathed CSS file, the local server is actually looking for http://127.0.0.1:8020/css/styles.css but it needs to get to http://127.0.0.1:8020/mysite/css/styles.css.
The initial "/" in your link (/css/styles.css) tells the server to go to the root directory of the server and start looking for the folder and files from that point ... but there is no css folder in the local server's root directory. It lives in /mysite/css/styles.css and that's why fskreuz suggests relative paths and using "../css/styles.css" instead.
Personally, I prefer absolute links (but that's just a personal preference and not in any way a challenge to or comment upon fskreuz's response). However, my local development setup is conducive to using them because I setup virtual hosts for the sites I work on. Using Apache, I setup a virtual host for each of my projects. With this, I can load something like http://dev.mysite.com in any browser on my computer and test my site/app in a way that makes it mirror my production setup.