Response.ContentType Sporaticly Changes For IE8 Using MVC?
Jan 6, 2010
We are running ASP.NET MVC on IIS6. We have started to notice a problem with IE8 clients. Almost all the time, the ContentType returned is 'text/html' but occasionally, it will be returned as 'application/xhtml+xml'. This is causing IE8 to try and download the file instead of rendering the contents in the browsers.
Where is the ContentType set in the ASP.NET/MVC pipeline?
View 1 Replies
Similar Messages:
Sep 17, 2010
how can i set Title for a page with Response.ContentType = "image/jpeg" ?
View 2 Replies
Aug 5, 2010
I've got an odd issue.I'm creating a DataTable type my application then converting it to a CSV so the user can download the data.
I set the content type like this:
context.Response.Clear();
context.Response.ContentType = "text/csv";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv");
var responseBuilder = new StringBuilder(data.Rows.Count * data.Columns.Count * 30);
Now, this works well for all data sizes in my development environment, and for small amounts of data on my production environment, but when it gets to a larger size (say, more than about 4000 rows) on production Firefox gives me the error:
XML Parsing Error: no element found
View 1 Replies
Oct 15, 2010
I'm using VirtualPathProvider and VirtualFile to send some Assembly Resource. The files are plain text files and I need to garantee that MIME "application/xml", "text/plain" or something like gets to the client Content-Type Response.Header.
I've tried setting:
[Code]....
But, still, "application/octet-stream" reaches the client side.
how to set ContentType on a VirtualPathProvider/VirtualFile scenario?
View 2 Replies
Apr 20, 2010
How do I set the contentType of an image I download?
I only need jpg, png and gif.
I want to set the contentType immediately after upload.
View 4 Replies
Aug 31, 2010
I would like to validate the .txt or .csv file that is uploaded using PostedFile.ContentType:
<asp:FileUpload ID="fileUpload" runat="server" Width="525px" />
Is "text/plain" the correct value?
if (fileUpload.PostedFile.ContentType != "text/plain") ...
View 2 Replies
Dec 23, 2010
Can we get the doc type and contenttype of a file from the filestream field?
View 2 Replies
Nov 1, 2010
Simple upload has been working for quite a while now, yet it seems to all the sudden not work (but only for specific file types). mp3 can upload, flv cannot (remember, this was all working before).After a little debugging, I discovered that a portion of my code is never being entered because I test something first:
[Code]....
I have discovered that resourceMediaFile.PostedFile is not null, resourceMediaFile.PostedFile.ContentLength is the correct size for the uploaded file, yet resourceMediaFile.PostedFile.ContentType is now null. I've literally had this work over 1,000 times with several files (including the one I'm testing with) and it consistently came back "application/flv".
What would cause ContentType to be null if the other attributes are not?
View 3 Replies
Jul 23, 2010
I am having a simple web service method which returns JSON serialized response. The attribute to web method is
[WebMethod, ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
As security of the return data is not a problem, I am Get enabling the HTTP response. On the client (browser) end, my code is as below
[Code]....
Everything works smoothly but occasionally on the web server's event viewer, I see the following error
"Request format is unrecognised for URL unexpectedly ending in /SomeWebServiceWebMethod"
After fiddling through the request headers using Fiddler, I figured out that if I make direct request to the webservice link, contentType header attribute is missing and that is what throws the error. There is a good post by scott guthrie explaining this. I am not able to replicate the issue and not sure what removes the contentType attribute from the request header occasionally.
View 2 Replies
Oct 12, 2010
I am using VB to upload image files to my server but am having problems. How can I use the ContentType to filter only image files? This is my code for my upload button which does not seem to be working. I can only upload bmp files:
[Code]....
Also, how can I show the user the image they uploade
View 2 Replies
Mar 3, 2010
I am not able tto understand the differnce between REspose.Expire and Response.ExpiresAbsolute?
Is it mandatory to use both toghter?
View 4 Replies
Jul 16, 2010
[Code]....
I am using this code to download and its working well for me.But i cant understand the code.Can someone explain me this code to me please?
Response.AddHeader is used to add a new HTML header,but what is an HTML header all about?and the parameters i am passing within it as the name and value;what are they?
View 3 Replies
Sep 20, 2010
So,I have this code:
[Code]...
Even though I have buffer set to false,no text is displayed.I have tried adding a response.flush,with and without changing the buffer value.What exactly is wrong?I've also tried it with and without the label(i.e. with or without just Response.Write)
View 2 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
Jan 13, 2011
Is it necessary to call Response.End() after Response.Redirect(url) Update for all the answers. Because some answers say that it's necessary and others say no, I have searched more and have found in msdn under remarks the following: Redirect calls End which raises a ThreadAbortException exception upon completion.
View 5 Replies
Aug 10, 2010
I'm using Response.Filter in order to implement stream compression in accordance with HTTP Request Header Accept-Encoding
Here's the important stuff:
if (AcceptEncoding.Contains("deflate") || AcceptEncoding == "*")
{
HttpApp.Response.Filter = new DeflateStream(PreviousOutputStream, CompressionMode.Compress);
HttpApp.Response.AppendHeader("Content-Encoding", "deflate");
}
By and large this works as intended. However, I'm in a situation where I'm using an ActionResult on an MVC Controller to serve up files to the user agent:
Response.Clear();
Response.Headers["Content-Type"] = contentType;
Response.Headers["Content-Length"] = contentLength;
if (Request.QueryString["dl"] == "1")
{
Response.Headers["Content-Disposition"] = "attachment; filename=" + fileInfo.Name;
}
Response.Flush();
Response.TransmitFile(fileInfo.FullName);
To be more exact, the action method returns new EmptyResult() after the Response.TransmitFile() call. This works exactly as intended without the Response.Filter modification.
In this situation, the response entity reaches the user agent garbled and unintelligible. FireFox's Poster addon shows empty entities or jumbled entities coming back.
View 2 Replies
Jan 20, 2011
I need to send an image (as a downloadable file) from an ASP web page. It is working correctly in every browser except for IE (all versions).
Here is the server side code:
bool export = Request.QueryString["Export"] != null;
if (export)
{
byte[] allBytes = File.ReadAllBytes(@"C:MyImage.tif");
Response.ContentType = "image/tiff";
Response.AddHeader("content-disposition", "attachment; filename="MyImage.tif"");
Response.OutputStream.Write(allBytes, 0, allBytes.Length);
Response.OutputStream.Flush();
Response.End();
return;
}
And here is the JavaScript:
$('#ExportFrame').attr('src', 'Default.aspx?Export=true'); // ExportFrame is an iframe
In IE, I keep getting an error saying "Internet Explorer cannot download Default.aspx from localhost". I thought it might be an issue with loading it in an iframe element, but redirecting to the URL is not working either. The really odd thing is that going to the URL (/Default.aspx?Export=true) does not work the first time, but works every time after that. Again, this works in every browser I've tried except IE.
Update:
The aspx page has the following code to keep the page from getting cached:
// Never cache this page
Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
Removing the first 2 lines and leaving only Response.Expires = -1 resolved the issue.
View 1 Replies
Nov 13, 2010
This page contains the following errors:
error on line 1 at column 2: StartTag: invalid element name Below is a rendering of the page up to the first error.
Why am i getting this error in while browsing a page from dreamweaver? Here is my source code:
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">; <html xmlns="w3.org/1999/xhtml">; <head><link rel="stylesheet" type="text/css" href="test.css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> </body> </html>
View 1 Replies
Jan 24, 2010
I have written simple HttpModule. context.Response.Output.Write is working fine. but not context.Response.Write().
View 2 Replies
Jan 13, 2010
I am using the async file upload control to upload to a image file. I want the user to upload only jpg files. And for that I am checking the uploadedfile content type in server side, after the upload complets. I wanna check this, before upload starts. There is one javascript method
function startUpload(sender, args){}
but how to access the content type of the file selected by user.
View 5 Replies
Mar 31, 2010
I have following function which is called from a button click event
[Code]....
I am creating a zip file on the fly and wanted to download this file.Problem is that in Internet explorer when I click the button the download accelrator comes with file name as my page saying resume opendialogueif i click open then DAP window close and normal windows download manager comes but the event of my button fires multiple time?I don't know what to do with it
View 6 Replies
May 12, 2010
When to use Response.Flush? Do I need to call it every time before I call Response.End?
View 2 Replies
Apr 22, 2010
what is difference between Response.write and Response.output.write
View 2 Replies
Nov 24, 2010
I've just finished reading URL vs. URI vs. URN, in More Concise Terms, and it's really helped understand the distinction between the three terms. Since then I've skimmed the RFC2141 and RFC2616 specs and Microsoft's Response.Redirect Method documentation in an effort to answer the following question confidently.
Given this line of code:
Response.Redirect("~/Foo.aspx");
And this resulting HTTP response (trimmed for context):
Status=Found - 302 Date=Wed, 24 Nov
2010 17:27:58 GMT
Server=Microsoft-IIS/6.0
X-Powered-By=ASP.NET
X-AspNet-Version=2.0.50727
Location=/MyWebApp/Foo.aspx
What name(s) most properly describes what has been placed into the "Location" header?
URL? URI? URN? URC? Which is it?
View 5 Replies
Mar 25, 2011
I wanna response the ascx file from my .dll
View 2 Replies