C# - How To Compress .ashx Content
Jun 2, 2010
In my web application I use an ashx file to write a file to the browser. I've noticed that there's no compression over the .ashx file, but only over my .aspx files.
Is it possible to compress .ashx? And if it is possible, how?
Currently I use global.asax to handle the compression:
<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.IO.Compression" %>
<script runat="server">
void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;.......
As you can see only files which inherit from 'Page' are compressed, and my ashx file is not of type Page. So I added a condition and now it works just fine:
if (!(app.Context.CurrentHandler is Page ||
app.Context.CurrentHandler.GetType().Name == "SyncSessionlessHandler" ||
app.Context.CurrentHandler is ViewMht // This is the type I had to add
) ||
app.Request["HTTP_X_MICROSOFTAJAX"] != null)
return;
View 2 Replies
Similar Messages:
Mar 4, 2010
What are the latest and greatest ways to compress the ASP.NET ViewState content?
What about the performance of this? Is it worth it to keep the pages quick and minimize data-traffic?
How can I make:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKMTM4Mjc3NDEyOWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgkFLGN0b
DAwJENvbnRlbnRQbGFjZUhvbGRlcl9NYWluQ29udGVudCRSYWRCdXQxBSxjdGwwMCRDb250ZW50UGxhY2VIb
2xkZXJfTWFpbkNvbnRlbnQkUmFkQnV0MQUsY3RsMDAkQ29udGVudFBsYWNlSG9sZGVyX01haW5Db250ZW50J
FJhZEJ1dDIFLGN0bDAwJENvbnRlbnRQbGFjZUhvbGRlcl9NYWluQ29udGVudCRSYWRCdXQyBSxjdGwwMCRDb
250ZW50UGxhY2VIb2xkZXJfTWFpbkNvbnRlbnQkUmFkQnV0MwUsY3RsMDAkQ29udGVudFBsYWNlSG9sZGVyX
01haW5Db250ZW50JFJhZEJ1dDQFLGN0bDAwJENvbnRlbnRQbGFjZUhvbGRlcl9NYWluQ29udGVudCRSYWRCd
XQ0BSxjdGwwMCRDb250ZW50UGxhY2VIb2xkZXJfTWFpbkNvbnRlbnQkUmFkQnV0NQUsY3RsMDAkQ29udGVud
FBsYWNlSG9sZGVyX01haW5Db250ZW50JFJhZEJ1dDXz21BS0eJ7991pzjjj4VXbs2fGBw==" />
Into sometning like this:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKMTM4Mjc3N==" />
View 6 Replies
Nov 12, 2010
I able to upload my file through uploadify + .ashx, but the problem is I always get ContentType = application/octet-streamLets say I upload an image, I expected to return me "image/pjpeg", but it always return "application/octet-stream" no matter what file I uploaded.how to get the correct contentType in .ashx
View 1 Replies
May 31, 2010
I have to let the user downloads a big text file.. By now I'm compressing the file with ".gz" (GZipStream)... And then the user can unzip in his machine.. But some users can't decompress the .gz extension.. And I wonder if there is any way to compress using zip..
View 2 Replies
Jan 17, 2011
Just spent a lot of time exorcising asp.net's large (but understandably useful) viewstate from an app, and i think it's worth sharing how it's done.
View 8 Replies
Sep 27, 2010
I am having a problem passing JSON from PHP server and ASP.NET server.
I am getting Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 48 bytes)
I am looking for a way to compress the JSON.
View 4 Replies
Nov 23, 2010
I have ScriptResource.axd file which is use and whithout compression. also I have JavaScript files that are not compressed too.
this is making website loads reallu slow....20 seconds....:
What can I do to reduce this and compress everything?
View 3 Replies
May 7, 2015
I want enable Gzip compresion inasp.net
I tried by adding following lines in web config
<system.webServer>
<httpCompression directory="%SystemDrive%inetpub
tempIIS Temporary Compressed Files">
[Code]....
View 1 Replies
Jan 5, 2011
We are trying to compress JS and CSS files in our application which is Running IIS 7.5. Both JS and CSS files are getting compressed
But application is not able to load these compressed .JS and .CSS files it is still referring to old un compressed files.
Just for your info Compress JS and CSS Files are at C:inetpub empIIS Temporary Compressed FilesDefaultAppPool$^_gzip_C^.
Here are the setting which i have in AppHost.config file
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />[code]..
View 1 Replies
Jan 23, 2011
I want that suppose user upload 2 MB image then from that image i want to generate 1 thumbnail image.To reduce its size , so i can get speed in loading. as my listing page contains many images.so i am getting to much loading time. SO can you tell me how can i compress image or get Thumbnail image?
View 1 Replies
Mar 4, 2011
How to Compress uploaded file using upload control and send the file to our directory...(C#)
I want to send file up to 600MB
View 1 Replies
Dec 27, 2012
Any way to compress bitmaps, jpeg, png images for space. The reason being i have a webform that takes in n number of images from a user and stores it to a mapped drive. what i want to do is compress those images to optimize on space on the drive.
View 1 Replies
Dec 30, 2010
In the past, with pages with large viewstate I have overridden the PageStatePersister class so when the state is saved I compress it. On Load I decompress it. I have haven't really thought about it, but could IIS handle something like this better? The reason I did this was to keep my pages slimmer because I have a lot of custom controls on the page and the viewstate was huge. This is where I got my original code from:[URL]
View 1 Replies
Mar 7, 2014
i am trying to compress video files by using gzip in asp.net.
View 1 Replies
Dec 18, 2010
What is the best library/software to compress the dynamically generated javascript on server? I use javascriptzip to do so statically. Any solution for .Net platform? P.S. compression involves removing unnecessary spaces + language compression like changing new Object() into { }
View 2 Replies
Feb 26, 2014
I am trying to upload large videos(more than 1GB) to youtube from webpage. But youtube is allowing me to upload max 8MB videos. So I want to reduce the size of the video and then upload the reduced video to youtube. So, how to reduce the video size.
View 1 Replies
Mar 24, 2010
we're looking to compress our gargantuan JavaScript files with GZip to speed up the page loads of our site. I know this can be done through IIS, but I can't seem to find a simple step-by-step guide on how to implement it.We're running IIS7.5 on Windows Server 2008 R2.
View 2 Replies
Mar 23, 2010
I have a typical reporting application:
Large report <-- HTTP Compression --> ASP.NET Web Server <-- ??? --> SQL Server 2008
Since I have so much (repetitive) data to send to the client, I would like both network hops to have compression.
Is there a transport-level compression setting for SQL Server?
View 2 Replies
Apr 6, 2010
I got an ashx file to create an image. I am referencing it via web.config like this:
<add verb="*" path="captcha.ashx" validate="false" type="eVoila.Security.Captcha.CaptchaImageHandler, eVoila" />
My handler looks like that:
[Code]....
Actually the handler never gets called. I already searched the forums and tried some tips and hints. But nothing of that worked. Try to call the url via[URL]
View 4 Replies
May 25, 2010
Can u explain me what ASHX HttpHandler uses for?
View 7 Replies
Nov 3, 2010
There is an ashx file containing "ProcessRequest(HttpContext context)" method which gets triggered automatically. When and how does it get fired?Another question, How can I get the current QueryString when I am inside this file? When I type "context.Request.QueryString" it says it's null or empty although the address have arguments.
View 1 Replies
Jun 23, 2010
I've got a simple ASHX handler that returns an dynamically generated image; the image is generated from a custom created class, and an object belonging to this class is passed to the handler using Session (I'd rather avoid using QueryString).The handler is used as the URL of an image on a ASP form which is very simple: a drop down list, a button and an image. Basically, depending on what the user selects from the list, the appropriate image will be generated once the button is pressed.
At the start the actual image has it's Visible property set to false; I don't want the handler to display anything before the data is all there.Once the button is pressed, the required Session parameter is added containing the necessary object, and the page is refreshed using Server.Transfer. When the Page_load method detects that the Session parameter has been correctly set, it sets the Visible parameter on the image to true.After that the handler fires up and generates the image.
So far so good... However, if the user now picks something different from the list and presses the button, despite the correct object being passed in the Session, the image won't be updated. In fact, the handler won't even fire up (if I put a breakpoint in there). I need to close the browser window and reopen it for it to work.Any ideas what could be the cause of such behaviour?I suspect the answer is very simple, and I just don't know something fundamental about ASP (or handlers)...
View 1 Replies
Mar 1, 2010
What is the Difference betweeen axd and ashx handlers.
View 3 Replies
Jun 29, 2010
My web site has a handler (FileDownload.ashx) that deals with all file download requests. I've recently migrated my site to ASP.Net 4.0, and it now uses routing extensively. Everything works fine when dealing with page requests (aspx), but it's not working with my handler - I encounter the following error:
Type '<snip>.Handlers.FileDownload' does not inherit from 'System.Web.UI.Page'.
This makes sense, as routing is only implemented in the page. So, my question is, what steps do I need to take to be able to use routing and my ASHX together? I want to be able to extract RouteData.Values from the url.
public class FileDownload : IHttpHandler
{
}
View 2 Replies
Mar 7, 2011
sitemap is at: http://localhost/scirranew/sitemap.ashx
<%@ WebHandler Language="C#" Class="SiteMap" %>
using System;
using System.Web;
[code]...
View 1 Replies