Image Upload - Local host interrupt - asp.net

I have implemented a small method
for my site where I upload an image. using a FileUpload control, I choose an image, and then when I hit a button, the UploadImage() method is generated.
The UploadImage() method stores the image in a folder in the server and stores its path in the Database. It also checks the file size of the image, if greater than a megabyte, an alert is displayed, else, the image is upload and stored. This has been tested with a few images ranging from 45KB to 900KB. It has worked perfectly.
THE PROBLEM:
When tested with a few images of approximately 4MB, sometimes it shows the 'error' since it is greater than 1MB, but at other times (I do not know why), Google Chrome directs me to a page telling me that the localhost has been interrupted.
When debugging, I do not even enter the button Upload click method! I find this very strange. The extension of the image doesn't seem to be the problem since I am testing with .jpg and .png.
Did some one experience the same problem? Is there a guru that can help me?
Thank you very much.
update:
it seems that files of 4052kb have worked correctly (i.e. an error message was displayed)
but files over 4098kb) resulted in a local host interrupt. When the button is clicked,
the browser below shows 'sending request' and uploading (0%) and displays "The connection to localhost was interrupted."

Please take a look at the maxRequestLength of the httpRuntime element of the web.config.
http://msdn.microsoft.com/en-us/library/e1f13641.aspx
This is where you set the maximum request length. When it is exceeded, the runtime throws an exception. The default size is 4096KB.

Related

IIS UploadReadAheadSize value meaning

Hi I'm encountering an error saying Request is too large in my Umbraco CMS when uploading large file. Now I've read that I need to modify the Configuration Editor in IIS specifically the UploadReadAheadSize now upon opening the configuration it's value is set to 41265 may I know if this is in KB? or MB? Basically I want to be able to upload file bigger than 20mb. What value should I place here?
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/serverruntime says
The maxRequestEntityAllowed and uploadReadAheadSize attributes respectively configure limits for the maximum number of bytes allowed in the entity body of a request and the number of bytes a Web server will read into a buffer and pass to an ISAPI extension.
(emphasis mine)
To increase the file upload limit in iis you could use the requestFiltering feature:
1)Open iis manager, select your site.
2)Select Requests Filtering and open it by double-clicking the icon. The Request Filtering pane displays.
3)From the Actions pane on the right-hand side of the screen click the Edit Feature Settings... link. The Edit Request Filtering Settings window displays.
4)In the Request Limits section, enter the appropriate Maximum allowed content length (Bytes) and then click the OK button.
5)Restart IIS.

wordpress unable to upload image, however some images get uploaded

I am unable to upload image in wordpress but sometime image gets uploaded.
I checked whether it is issue with image size more surprisingly sometimes i am able to upload higher size image and sometime not.
While uploading, in browser developer console it shows
Request URL: http://srintimates.com/wp-admin/async-upload.php
Request Method: POST
Status Code: 404 Not Found
Remote Address: 107.180.44.152:80
Referrer Policy: strict-origin-when-cross-origin```
However the file http://srintimates.com/wp-admin/async-upload.php is there in server.
Check your server is are space to upload ?
And what is the message you see in front wp-admin
Your question is unclear

set expires http header on images in IIS7

I'm trying to set my images to cache. With no settings, I'm getting a 304 response from the server, which means that while 100 requests are being made for each of my images, the image isn't actually being transferred.
Great.
Now I want to tell the browser to use the image from cache without making the request to see if it was modified.
I go into IIS7 and click on the folder with my images, select the HTTP Response Headers and click Set Common Headers.
On the dialog the apears I check off the "Expire Web Content" box and I select the "After" option and I select 1 Day(I also tried 2 days).
I click OK and run a iisreset (although I don't think this is nessesary). I open up internet explorer with the network tab active and load the page. The browser loads the images. They are 200 responses and I check the headers and find "Cache-Control:max-age=172800" Great.
Now I reload the page (clicking on a link that loads the same page, or clicking in the address bar and pressing enter... NOT clicking refresh) and check the network tab again. I'm still getting 304 repsonses from the server, the browser is not directly loading the image from cache.
What do I need to do to get the browser to load this from cache?
Note: This works correctly in Chrome (Of course, story of my life)
Note2:
Someone noted that sometime IE says 304 even though it is really going strait to cache.
I don't see it going through Fiddler, HOWEVER, I see in the network tab of IE9 it is saying the Response time is 327 milliseconds. This time seems to increase for the images that are loaded later. So out of the 100 images the first 10 had respnses between 16-70 ms and the last 10 had responses of over 800 ms. The one that took 327ms was somewhere in the middle. Is IE really this inefficient retrieving from the cache?
Also, I should note there are files, such as some css files, that IE says are 304, however the response time is <1ms, which I'm assuming means it actually got it from cache without going over the network. That's different than this case for my images where IE actually shows a response time of hundreds of milliseconds.

How can I serve a tracking image that won't get removed by Hotmail?

I'm building an emailshot tracking function in my ASP.NET site which will serve up a linked image when the email is opened, so allowing me to count the email opens.
It's all above-board, opted-in etc, etc, and I've tried two methods:
calling a .aspx page that serves (direct to the Response stream) a Base64-encoded image stored in a database
calling a .ashx HTTP handler that serves an image from a physical folder
Both of these techniques work absolutely fine - the image is served, and I can process the hit in the page code - if I use my POP email or my Gmail accounts.
However, Hotmail blocks them both. It doesn't even give the option of displaying images - there's no trace of the original link if I View Source on the browser email display.
Links to images only seem to display correctly in the Hotmail browser window if I:
Use an actual domain name in the link (rather than an IP address or localhost for testing) AND
Link to physical files (rather than pages that serve them) using <img src="http://domain/imagefilename.ext"/>.
Is there an alternate approach that will at least give the option of viewing the image? I'm not trying to conceal the tracking in any way - there will usually be other linked images in the emails anyway.
Nor does the thing being served have to be an image - is there anything else that can be served (and hence counted) that isn't treated as suspicious by over-zealous mail servers such as Hotmail?
Cheers.
You can add a querystring value at the end of the url. And then configure IIS to handle that extension.
WELL what are you asking is a nightmare for email server.this same technique is used by spammers to get valid emailid out of junk emailids. For now i can assure you tracking opening of email is impossible using any white hat or gray hat techniques on any reputiable servers.
plese see these links for more details:-
http://emailuniverse.com/ezine-tips/?id=502
https://webapps.stackexchange.com/questions/22662/way-to-ensure-that-my-sent-email-was-read
However dont take myword 'impossible' for granted, there are some protected techineques available but i am not sure about it
http://mailchimp.com/
good luck

What does "pending" mean for request in Chrome Developer Window?

What does "Pending" mean under the status column in the "Network" tab of Google Chrome Developer window?
This happens when my page script issues a GET request whose response contains content-headers for downloading a CSV file:
Content-type: text/csv;
Content-Disposition: attachment; filename=myfile.csv
This works fine in FF and IE7, downloading a CSV file as expected and opening a file picker to save the file, but Chrome does nothing. I confirmed that the server responds to the request, so it appears that Chrome will not process the response.
Curiously, all works as expected if I type the URL into Chromes address bar and hit <enter>.
FYI: Chrome 10.0.648.204 on Windows XP
In my case, I found that the "pending" status was caused by the AdBlock extension. The image that I couldn't get to load had the word "ad" in the URL, so AdBlock kept it from loading.
Disabling AdBlock fixes this issue.
Renaming the file so that it doesn't contain "ad" in the URL also fixes it, and is obviously a better solution. Unless it's an advertisement, in which case you should leave it like that.
I also get this when using the HTTPS everywhere plugin.
This plugin has a list of sites that also have https instead of http. So I assume before the actual request is made it is already being cancelled somehow.
So for example when I go to http://stackexchange.com, in Developer I first see a request with status (terminated). This request has some headers, but only the GET, User-Agent, and Accept. No response as well.
Then there is request to https://stackexchange.com with full headers etc.
So I assume it is used for requests that aren't sent.
I had some problems with pending request for mp3 files.
I had a list of mp3 files and one player to play them. If I picked a file that had already been downloaded, Chrome would block the request and show "pending request" in the network tab of the developer tools.
All versions of Chrome seem to be affected.
Here is a solution I found:
player[0].setAttribute('src','video.webm?dummy=' + Date.now());
You just add a dummy query string to the end of each url. This forces Chrome to download the file again.
Another example with popcorn player (using jquery) :
url = $(this).find('.url_song').attr('url');
pop = Popcorn.smart( "#player_", url + '?i=' + Date.now());
This works for me. In fact, the resource is not stored in the cache system. This should also work in the same way for .csv files.
I had the same issue on OSX Mavericks, it turned out that Sophos anti-virus was blocking certain requests, once I uninstalled it the issue went away.
If you think that it might be caused by an extension one easy way to try and test this is to open chrome with the '--disable-extensions flag to see if it fixes the problem. If that doesn't fix it consider looking beyond the browser to see if any other application might be causing the problem, specifically security apps which can affect requests.
I had a similar issue with application/json ajax calls. In ff/IE they were fine. In chrome in the Developer Network window Status was always (pending) because a different status code was being returned.
In my case I changed my Json response to send a HttpStatusCode of 200 then Chrome was fine and the Status Text changed to 200 OK.
For example using ASP.NET Web Api
return new HttpResponseMessage(HttpStatusCode.OK ) {
Content = request.Content
};
The Network pending state on time, means your request is in progressing state. As soon as it responds the time will be updated with total elapsed time.
This picture shows the network call is in processing state(Pending)
This picture shows the time taken in processing by network call.
The fix, for me, was to add the following to the top of the php file which was being requested.
header("Cache-Control: no-cache,no-store");
Same problem with Chrome : I had in my html page the following code :
<body>
...
<script src="http://myserver/lib/load.js"></script>
...
</body>
But the load.js was always in status pending when looking in the Network pannel.
I found a workaround using asynchronous load of load.js:
<body>
...
<script>
setTimeout(function(){
var head, script;
head = document.getElementsByTagName("head")[0];
script = document.createElement("script");
script.src = "http://myserver/lib/load.js";
head.appendChild(script);
}, 1);
</script>
...
</body>
Now its working fine.
Encountered a similar issue recently.
My App is in angular 11 and we have a form with some validators which have regex to validate the data. One of data element had a special character which the regex wasn't handling and it made the entire browser hung up. Infact, even though all network calls were successful with 200 Ok, chrome was not showing any response returned by the backend and was also showing the requests in Pending State when infact all network calls are successful, there was no console log errors or anything. Handling the regex fixed the issue.
After i found the issue, i googled more about it. Here is more explanation about it.
https://javascript.info/regexp-catastrophic-backtracking
I came across this issue when I was debugging a local web application. The issue turned out to be AVG Antivirus and Firewall restrictions. I had to allow an exception through the firewall to get rid of the "Pending" status.
In my case, a simple restart to my browser (chrome) and it worked straight away afterwards like magic!
Little bit of context, I happen to refresh my frontend web page and straight away went onto making a changes to my API which led it to restart. During that instance, the frontend was making calls to API which led into "pending" due to that API is reloading. Browser at this point cached that pending state. For me to get out of it is either I set no-cache (which I didn't want to) or simply restart the browser, I chose the restart.
A little background
I encountered such an issue when requesting an url in my Django project. The server is setup using Apache HTTP web server and basic auth for user authentication.
The url I was accessing required no authentication to access i.e. in my Apache config, I had set Require all granted on the url using the LocationMatch directive.
The issue
The url I was trying to access returned 200 status (in the Network tab in Chrome), but the static assets being used for styling of the requested webpage (css, javascript, font files etc.) associated with the request url were not loading and returned pending status.
In the meanwhile, the page loaded partially and still kept on loading. All this was happening in the presence of basic-auth dialog in browser, even though my url was granted all access.
What worked for me
Interestingly, as I entered my credentials and logged in, the requested page loaded all the static assets. This made it very clear to me that the static assets directory might NOT have the necessary access permissions.
Then, I granted the access to the static assets directory by updating my Apache config and then the requested url and the webpage loaded up fine (200 status) without any basic auth dialog OR pending status.
In my case, there's an update for Chrome that makes it won't load before you restart the browser. Cheers
I encountered the same problem when I request certain images from page. I use JavaScript to set the src attribute of an img object and if the network is poor pending will be displayed in the network panel of chrome developer window. I think it's due to the poor network.

Resources