Web Forms :: IIS7 Response.OutputStream Does Not Work In IE7?
Apr 2, 2010
The application is hosted in Windows Server 2008 with IIS7.
I have a button that calls a new webpage (asp.net page, ext .aspx) that contains
Response.OutputStream.Write(blahblahblah) which then should prompt a download box to allow user to save an image.
Now the page basically creates a stream and then is supposed to output the stream to the user using Response.Outputstream.Write.
Then the user is supposed to be prompted to open or save the document. This works fine in Firefox but it does not work with IE7 or 8
Also this exact same code works with IIS6 on a Windows 2003 server.
So the only differences is the IIS6 and Windows 2003 Server to IIS7 and Windows 2008 Server.
And what happens is when I clicked the button, the page did pop up but disappear 1-2 seconds later without
prompting the download box to the user.
Here is the code that launches for Reference
//e.g file = 123424_43535.jpeg
FileInfo myFile = new FileInfo(Server.MapPath("mapImage/") + file;
using(var fs = myFile.Open(FileMode.Open, FileAccess.Read))
{
byte[] buffer;
int read;
buffer = new byte[(int)fs.Length];
Response.AddHeader("Content-Disposition", "attachment;filename=" + file);
Response.ContentType = "application/x-force-download";
Response.AddHeader("Connection", "Keep-Alive");
Response.AddHeader("Content-Length", fs.Length.ToString());
while((read = fs.Read(buffer, 0, buffer.Length)) > 0)
{
this.Response.OutputStream.Write(buffer, 0, read);
}
}
Response.End();
I have tried to replace Response.AddHeader with Response.AppendHeader, however the result is still the same. Also, I have tried to replace the Response.ContentType with application/octet-stream and image/jpeg, I also faced the same result.
Is there any setting/modification on server/code that I need to look on?
View 13 Replies
Similar Messages:
Feb 4, 2010
How do I write Response.OutputStream to a file preferably in C#?
View 2 Replies
Jan 27, 2010
I'm using the technic described in: [URL]
to allow users to download files. Our group uses a tool called SecureGateway which doesn't seem to like FTP as a protocol.
Smaller files don't seem to have a problem, but intermittently larger files (larger than 10K) will not download to the client properly. They will just abruptly end the transfer as if they are actually completed.
I use the following code:
{
System.IO.
Stream iStream =
null;// Buffer to read 10K bytes in chunk:
byte[] buffer =
new
Byte[10000];// Length of the file:
int length;// Total bytes to read:
// string filepath = "DownloadFileName";
long dataToRead;// Identify the file to download including its path.
String filepath = Request.Params["file"].ToString();//
Identify the file name.
string filename = System.IO.Path.GetFileName(filepath);
try
{
// Open the file.
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,FileAccess.Read,
System.IO.FileShare.Read);
// Total bytes to read:
dataToRead = iStream.Length;
Response.ContentType = Response.AddHeader("application/octet-stream";"Content-Disposition",
"attachment; filename="" + filename +
""");
// Read the bytes.
while (dataToRead > 0)
{ // Verify that the client is connected.
if (Response.IsClientConnected)// Read the data in buffer.
{
length = iStream.Read(buffer, 0, 10000);
// Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer = new
Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
}
{
catch (Exception ex)// Trap the error, if any.
{
Response.Write("Error : " + ex.Message);
}
finally
{
if (iStream !=
null)//Close the file.
iStream.Close();
}
}
}
I know that there is a preset size restriction that you have to override when uploading a file to the server, just wondering if someone knows of a similar issue with downloading to the client.
View 6 Replies
Nov 19, 2010
I have a static method that I use to control REST styled HTTP codes when my mvc application encounters an exception.
The method looks like:
[Code]....
This is static becuase then I can call it within an action or inside a filter. The problem I am having is that when I call RaiseException inside a filter, it stills goes into the requested action. Response.End() doesn't seem to have any effect. Any clues on how I can get Response.End() to work when called?
View 19 Replies
Jul 14, 2010
I am using a script manager for ASP.NET MVC to combine and compact CSS files and JavaScript files for pages on a website. For the most part this works as expected, however there are times (couple of times per week) when the HTTP handler responsible for returning the content returns an empty response and so pages load without any CSS - the HTML returns and the images load as well. When this happens, refreshing the page does not resolve the problem, while resetting IIS always resolves the problem. Also, without resetting IIS, after some time the problem stops.
Normally the script handler logs errors, however there are no errors logged during the issue. It seems as if the handler is never invoked. There are no failed request logs generated by IIS.
I monitored resource usage when this was happening and did not notice anything out of the ordinary. The web server is running IIS 7 and has low CPU usage. I increased some parameters in IIS settings regarding the number of allowable requests to process, the problem still exists though perhaps less frequent. The website receives about 1.5 million pageviews monthly.
View 1 Replies
Mar 3, 2010
I have a custom implementation of Application_PreRequestHandlerExecute which is applying a deflate/gzip filter to the response. However, on IIS7, this is failing on my "script generator" pages. These aspx pages take in Query String values and return a custom bit of script, changing the response type to text/javascript. I think it is failing because of the way iis7 uses mime types, but I'm unsure how to fix it short of turning all compressio off.
View 1 Replies
Mar 5, 2010
I'm moving applications from IIS6 to IIS7.5 (win 7 an win server 2008 r2), when 2 applications (with identity impersonate) try to get a file with response.writefile only from a UNC path i'll get "access denied". In IIS6 and Visual Studio Developer Web Server, same code works. I can save file with FilePath.SaveAs and get name and length with FileInfo, but not download. After 2 days of nightmares I have tried to change
Response.WriteFile(filePath)
to
Response.BinaryWrite(File.ReadAllBytes(filePath))
and now work. My question is: can I have a microsoft developer to sacrificate for my avenge?)
View 2 Replies
Jul 21, 2010
Okay I've read the other StackOverflow postings, forum posts on MSDN, everywhere. I CANNOT get this to work for the life of me.
Here is what I have setup.
In IIS7.0
- Default Site in ASP.NET v4.0 App Pool
- C:Inetpubwwwroot as the physical path
I published my MVC2 site in VS2010 to the Default Site path, it succeeded.
Here are the settings for that:
- Same App Pool
- C:InetpubwwwrootPerfectSchedule as the physical path
- Default Document is Views/Home.mvc
I open the URL in my IE browser
- http://localhost/ --> just gives me the Apache "It works!" page
- http://localhost/PerfectSchedule --> The WebPage cannot be found
- http://perfectschedule/ --> Internet Explorer cannot display the webpage
View 2 Replies
Feb 27, 2011
I get a website working perfectly in VS2008 but when I publish it on IIS7 ajax doesn't work at all.I guess it is a problem in my web.config but I don't know what. Here is the web.config file :
[Code]....
View 4 Replies
Nov 19, 2010
In my local enviroment it just works. Iam no IIS Admin so ....
i try the following
My domain "http://mysite.com/" goes to my url provided by my hosting service (discountasp.net)
I want that this url goes to the root/mysite/ virtual directory but i want that the url stays on "http://mysite.com/". So i defined the following rule, but it doesnt work for me.
here is my web.config that is placed in the root directory (generated by the IIS7 Remote Administration UI)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>[code]....
View 1 Replies
Feb 16, 2011
in my testpage, i'm trying to redirect to a file in another folder of the web application. for that i've used
[Code]....
and unfortunately it is not redired to the desired page.
View 4 Replies
Nov 23, 2010
http://blogs.msdn.com/b/tmarq/archive/2009/06/25/correct-use-of-system-web-httpresponse-redirect.aspx
http://weblogs.asp.net/bleroy/archive/2004/08/03/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_.aspx
I've followed the instructions in the two articles above, plus more and I still cannot get response.redirect to work. I am able to see the url of the page I am trying to redirect to in fiddler but the browser does not navigate to the page. I am using Cassini as a web server, could that be the problem?
Here is global.asax
[Code]....
View 5 Replies
May 25, 2010
I been trying to get my Visual Studio 2008 to run my Web Application on IIS7 on my Windows 7 machine but I just can't get it to work. I'm using the SQLEXPRESS I been following this Tutorial, but I get the following error message.
"Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. make sure the user has a local user profile on the computer. The connection will be closed."
my connectionString seem to be ok
[Code]....
The site run with out database connection.
View 3 Replies
Sep 21, 2010
Here are the structure of my web site:Login.aspx in the root pathUserInfor.aspx and 1.txt in the sub-directory folder named 'Restricted' Authenticate this website with form authentication configured in IIS, and does not allow anonymous to get into the Restricted folder with the web.config file.I think it should work this way, if I manually access the 1.txt in the browser, I should be able to view the content, and if I go to the modules configuration for this applicaiton in IIS7, find the 'UrlAuthorization' module, and cancle the listbox for 'invoke for requests to asp.net ...', I should be directed to the loginurl setting in the root web.config file when I access the 1.txt file without logging, however, I still can see the content of 1.txt.
View 1 Replies
Nov 11, 2010
We have a web application which is changing to a new page using response.redirect("MainMenuPage.aspx"). It is running under framework 3.5.
The code has been working for years on 2.0 and 3.5 running on Windows2003. Now we migrated it to 2008R2 we have some problems.
The code is running ok on Windows7 Visual Studio 2010 in debug mode.
On the server there is no error logged.
Symptom is that when the user is redirected to the main menu page, the hour glass comes on the browser and nothing else happens for about 1 hour, then the browser returns a dns error.
As this does not occur in debug and and there is no error on the server, it is quite difficult to see what the problem is, but we are fairly sure it is coming from the response.redirect line.
View 3 Replies
May 11, 2010
We had some content restructure recently and I'd like to put in some redirect rules into web.config so bookmarks to the old pages can get routed to their new locations/pages.I tried using this approach:
<location path="~/product/productA.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="~/product/category/productA.aspx" exactDestination="false" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>
But all I'm getting when I go to "[URL] is our http 404 page.Am I doing something wrong, or is the httpRedirect tag in web.config not supported in mono?
View 1 Replies
Mar 21, 2011
I'm simply adding to a set of rules on existing rewrite rules for our company website. We have a file that we need to restrict to only our internal IP addresses. The URL is http://oursite.com/internal/index.aspx?u=blahblah and need it restricted to IP ranges 10.1.X.X. I'm adding this and it's not doing anything. Even if I tried to capture all using .* for the pattern, it still ignores it. Is my syntax correct?
<rewrite>
<rules>
...
<rule name="Restrict URL" enabled="true" stopProcessing="true">
[code]...
View 1 Replies
Nov 9, 2010
I'm using .net 4.0 and iis 7 and windows server 2008
my web application use form athentication and wok properly in vs 2010
but when i try to config the web site in iis 7 the form athenticate redirection doesn't work without any kinds of error.
here is my web.config code
<authentication mode="Forms">
<forms loginUrl="Pages/login.aspx" name=".ASPXFORMSAUTH"></forms>
</authentication>
<authorization>
<allow users="?" />
</authorization>
I enabled the authentication form in iis.
View 3 Replies
May 21, 2010
We have an aplication which works fine withing ASP 2.0 .NET Framework 3.5. Its a response. redirect call from inside ajax update panel, and it can not be outside. After updating to Framework 4.0 it no longer funchtions and returns "Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed." without redirecting.
Server.trasfer gves the same error as well as and does not work
View 2 Replies
Sep 9, 2010
[URL]I know how to remove the Server response header with an HTTP Module based on the link above. I just want to know why it is necessary to remove it this way.
View 3 Replies
Jan 2, 2011
am trying to write an HttpModule that will work in IIS7 with integrated pipeline mode AppPool. Within this module I need to access Session variables and to be able to capture the Session Start and End events. I have found a couple of articles on this topic that indicate the need to modify the behavior of the HttpHandler in PostAcquireRequestState to force the Session for the context to be initialized. The article I am using as a template is posted here:[URL]In my case I am getting the following error:
[NullReferenceException: Object reference not set to an instance of an object.] System.Web.PipelineModuleStepContainer.GetEventCount(RequestNotification notification, Boolean isPostEvent) +30 System.Web.PipelineStepManager.ResumeSteps(Exception error) +1112
System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +113 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +616
I believe that this error implies a problem with attempting to attach an event handler multiple times. I am aware that the modules Init function can be called more than once and have set a static initialization flag which ensures that I will only ever attach the event handler once.In the most condensed form my code is as follows:
public class HttpModule : IHttpModule, IRequiresSessionState
View 1 Replies
May 5, 2010
this is my function which converts pdf to png image, it's throwing an error onthis line--> stream.WriteTo(Response.OutputStream); Is there some thing wrong??
protected void CreatePngFromPdf()
{
try
[code]...
View 2 Replies
Jan 21, 2011
I am trying to write out some dynamic contents on a cached page with Response.WriteSubstitution but it doesn't work. Besides, HttpRuntime.Close() is not clearing my output cache. I read the following thread on MS Connect and was quite shocked.
"Due to a change in how ASP.NET MVC 2 views are rendered certain functionality will no longer work...". It seems kind of foolish to remove this feature. Can anyone explain how I should use output caching in ASP.NET MVC if I can't have dynamic portions of a cached page?
[URL]
View 7 Replies
Feb 17, 2010
I am working on a tool which audits access to existing web application. Existing app does not have any hooks in place, but my plan is to inject an IHttpModule by modifying web.config and log whatever I need to log during EndRequest event.
What I'm struggling with right now is: I cannot intercept what is application writing to an output stream. I need to know what output does the application send to the client. Originally, I hoped I could run a code in BeginRequest to replace HttpContext.Response.OutputStream with a stream of my own, which would be flushed to original stream during EndRequest, but the stream only has a get accessor, so I cannot replace it.
I could of course use reflection to assign to private member of HttpContext.
View 2 Replies
Jan 6, 2011
I am trying to redirect to a page and send two values.
Now the second value is the value of a text box and If I type something one character or anything without space character then the redirect works but If I type two strings for second value or anything with a space then the redirected page hangs and shows a blank page. I am using-
Response.Redirect("Changes.aspx?id="+CustomerId+"&Req="+txtRequest.Text);
If I use value id= anything applicable and Req="A" then it works
but If I use value id= anything applicable and Req="A(space)B" then the next page hangs with a blank page.
View 9 Replies