Why is ASP.NET gzip compression corrupting CSS? - asp.net

I have an ASP.NET webforms application (3.5 SP1) that I'm working on, and attempting to enable gzip fpr HTML and CSS that comes down the pipe. I'm using this implementation (and tried a few others that hook into Application_BeginRequest), and it seems to be corrupting the external CSS file that the pages use, but intermittently...suddenly all styles will disappear on a page refresh, stay that way for awhile, and then suddenly start working again.
Both IE7 and FF3 exhibit this behavior. When viewing the CSS using the web developer toolbar, it returns jibberish. The cache-control header is coming through as "private," but I don't know enough to figure out if that's a contributing factor or not.
Also, this is running on the ASP.NET Development Server. Maybe it'd be fine with IIS, but I'm developing on XP and it'd be IIS5.

Is it only CSS files that get corrupted? Do JS files (or any other static text files) come through ok?
Also can you duplicate the behavior if you browse directly to the CSS file?
I've only enabled compression on Windows 2003 server's IIS using this approach:
IIS → Web Sites → Properties → Service tab, check both boxes
IIS → Web Service Extensions → Right click, Add New
Name
Http Compression
Required Files
%systemroot%\system32\inetsrv\gzip.dll
IIS → Right click top node, Internet Information Services, check Enable Direct Metabase Edit
Backup and Edit %systemroot%\system32\inetsrv\MetaBase.xml
Find Location ="/LM/W3SVC/Filters/Compression/gzip"
Add png, css, js and any other static file extensions to HcFileExtensions
Add aspx and any other executable extensions to HcScriptFileExtensions
Save
Restart IIS (run iisreset)
If you have a Windows 2003/2008 server to play with you could try that approach.

If you will be deploying on IIS 6 or IIS 7, just use the built-in IIS compression. We're using it on production sites for compressing HTML, CSS, and JavaScript with no errors. It also caches the compressed version on the server, so the compression hit is only taken once.

Related

Using IIS Server instead of IIS Express in Visual Studio 2015

How can we configure our already developed ASP.Net website to use IIS Server instead of using IIS Express in VS2015?
IIS Express is the default server in Visual Studio 2015. My website runs fine with ASP.NET web Development server in Visual studio 2012 but when i run it in VS2015 , it does not loads the css and images .
So, i want to run it with IIS Server and not IIS Express in VS2015. Can anyone help me out ?
Project Properties -> Web -> Servers -> Change IIS Express to Local IIS -> Check Apply server settings to all users -> then Project URL to http://localhost/Example (your project)
Then build your project.
The problem with loading the CSS and Images is likely because of the paths you have used, not with the web host.
"/Images/Image1.jpeg" always looks for an Image subfolder with an Image1.jpg in the same place as the current page.
"~/Images/Image1.jpeg" will look for an Images folder with an Image1.jpg starting from the site root. Using the tilde (~) is going to address other things as well (user controls, pages in folders, etc.
The same holds true for stylesheet hrefs. If you want to diagnose this kind of "resource failing to load" problem, you can use the developer tools (IE, Chrome, FireFox/FireBug, Safari all have them) and start a capture on the network tab. That will list a request to each resource (image, css, js, etc) and what the request path and HTTP status (404 - not found, 200 - OK, etc) is.
EDIT: Aside from the above which is directed to help you find the source problem of not loading CSS and Images, you will have to do a few things.
Create an application in your local IIS's Default Web Site that points to your project's root.
Make sure the Build and Start Options tabs are set correctly in the website project properties. Be sure to set the "Use custom web server" value with the URL you created in local IIS.
At that point you should be able to Start Debugging, but you should really consider conversion to a Web Application if you want a less fragile program and an easier development experience.
Key differences between WS/WAP - https://msdn.microsoft.com/en-us/library/dd547590(v=vs.110).aspx
Converting from WS to WAP - https://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx
Right click on your project and go to Properties and then Web. On servers section change the IIS.

SWF works on web not intranet

I have a SWF that works on the web but not over an intranet. The SWF loads it's initial XML content by binding to an asmx HTTP handler. Same code - different servers. On the intranet - a right click shows a SWF context menu - but there is no content rendered. IIS is serving up the correct MIME type (swf/flv) so I think it might be a client issue. The problem occurs on IE/Chrome/FF. Have adjusted browser intranet security settings and looked in advanced settings - no joy yet.
problem solved. the SWF is licenced to work on a specific www domain only.

How to configure the web page of a web application to be browsed maximized?

I have developed a web project using PowerBuilder V12.0 and it is published in ASP.net web file formats (*.aspx).
I have hosted my web project on a web server machine with operating system (Windows Server 2003 - Enterprise Edition) and IIS V6.0 as Web Server Hosting Application.
I would like to make the home page (Default.aspx) opened maximized so that no internet toolbars appears in the Internet Explorere or any other internet browser like Firefox and so on.
It seems this is a web server configuration and setting as now I host the same web application in two development web servers and it opens maximized in one of them and opens normal in the other so No changes are needed in the web project files.
I do not know exactly what is this option or configuration,, Is there a property like window size or width and height in web configuration files like web.config and machine.config ? I guess there is a property like WindowSize:Maximized.
If you had experience with that before please let me know the options and configurations needed to do that.
Thanks for your help.
You can use JavaScript to resize the browser window but I think it's generally bad form and not always supported. Some browsers won't do it at all, some will block it, etc.
Pretty sure you can't control any other aspects of window display, such as toolbar visibility, etc. Well - you can when opening new browser windows but you can't enforce this on the first load of the page.
http://www.w3schools.com/jsref/met_win_resizeto.asp
Tried it in Chrome, no worky, tried it in IE, you get "IE has restricted this webpage from running scripts..."
I can see why you would want to enforce how your web app is displayed but that's something that's really left to the client.

Gzip ASP.NET in debug mode

I've tried to setup compression (both dynamic and static) in IIS7 for my local system, but when start my ASP.NET site using the debugger, YSlow tells me that all of the files (aspx, js, css, etc.) are not compressed. Any ideas? I really want to test this before I make changes to the production server.
Are you using Cassini as your server? If so it does not support compression that I know of.
You might try using Fiddler to see what the accept headers are that are being sent back and forth:
Fiddler
Enable compression on dynamic content in IIS7
Problem with GZIP transfer using webrequest

IIS 7.0 with pipeline mode = Integrated doesn´t load any image/css in ASP .NET

I have a full system working in IIS 5.1 ...
I migrated to IIS 7.0 with pipeline mode classic all works fine, but with pipeline Integrated my images/css are not loaded...
I´m using ASP.NET 3.5 with a Web Application...
Any help?
In IIS 7 when you install the ASP.NET modules, static content is not installed by default. You will need to go into programs and features, then "Turn windows features on or off".
Under IIS section, drill down into WWW services, Common Http features, and check "Static Content".
Without that css, images, html, and other non-dynamic content will not show up.
I was having the same issue, my static content was not installed. To change the setting under server 2008, get to Server Manager, open Roles and click Web Server (IIS). Once it populates find the Role Services section then Add Role Services to install the Static Content.
You can use some HTTP sniffing tool (Firebug or Fiddler) and check for failing requests. If you find such requests you can inspect the error message returned by the server.
I also found this to be a side effect of having a corrupted default document inheritance. We typically add "login.aspx" to the top of a the default documents list in the parent (Default Web Site) configuration. When this somehow became corrupted displaying this same symptom.
The fix was to remove the inherited value and re-add it. I could then see static content again using a .NET 4.0 integrated app pool.

Resources