'Delphi 11. Web Server. local CSS does not render correctly
I have created a simple web server using tWebModule. I have created a standalone for testing, and an ISAPI DLL for deployment to IIS. Both use the same code. I would like to use local css files in case my app is used where internet is not available.
When I browse to the standalone server, the css does not render correctly. When I browse to the IIS server, the page renders properly. (see image)
If I use the Rest Debugger, it tells me that the local css is being delivered as "text/css" [typo] If I use a remote server (internet) for the css it renders correctly in both servers.
I have run the standalone as Administrator and still no joy.
Solution 1:[1]
This is my code (and changes)
s := Split(Request.PathInfo, '/');
if s[1] = 'assets' then
begin
if (s[2] = 'css') and (fileExists(style + s[3])) then
begin
Response.ContentType := 'text/css';
Response.ContentStream := TFileStream.Create(style + s[3], fmOpenRead);
// page.LoadFromFile(style + s[3]);
// Response.Content := page.Text ;
end
else
page.Add(s[3] + ' does not exist!');
if s[2] = 'js' then
page.LoadFromFile(scrip + s[3]);
end
Originally, I was loading the css into a tStringList, and then sending tStringList.text. Now I open a filestream to the css.
I don't know why this works, but I hope it can help someone else.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | thrutch |

