Main Site Documentation

Read a css file on my webServer


#1

Hi !

Firstly, I’m using a FezHydra device.

I created a web serveur based on an idea derived from this project:

http://www.ghielectronics.com/community/codeshare/entry/676

My server run my html page.
but the line:

doesn't work :(

I don’t know how my html can read my css.

I read in many subject that I need to place my css file in MicroSdCard.

I did it. I can read file but I don’t know what to do after…

I looked for answers in this project http://www.ghielectronics.com/community/codeshare/entry/363 but it’s very difficult for me. I didn’t find what I want.


#2

exactly I’m not sure that my line <link href … send a request to load the project css

When I click on my link I have a web page with HTTP/1.0 404 Page introuvable
source is http://172.16.8.89/projet.css


#3

You can open “Developer Tool” F12 in IE or Chrome and monitor all the request that are done behind the scene. I am sure there is 404 for css.

As andre.m said your server has to serve that resources when it asked for it. Means you have to include the css file in one form or another to your device and return it when the server is asked for it.


#4

For me css on EMX work ok(On NET 4.1 FW). I have files(css and images) on SD card in folder:
\http\css
\http\images\

In HTML(loaded from Resources) I use next code:


<html>
	<head>
		<link rel="stylesheet" href="/css/style.css" type="text/css">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Title</title>
	</head>

...

<html>

To start WEBServer you just simply add virtual directory and load pages like this:


web_server = new WEBServer(http_port);
web_server.AddVirtualDirectory("/", _root_directory + "\\http", true);
//Load pages

I think that your problem is missing / in href to css :slight_smile:


#5

this is my error:

La feuille de style http://172.16.8.89/project.css n’a pas été chargée car son type MIME, << text/html>>, n’est pas <<texte/css>>

fr > eng translation …

style sheet http://172.16.8.89/project.css didin’t be loaded because it’s type MIME, << text/html>>, is not <<texte/css>>


#6

Interesting article descripting use of css in Web server : http://blogs.msdn.com/b/laurelle/archive/2013/04/05/web-server-and-css-files-in-netmf-net-microframework.aspx