C# - BinaryWrite Of MHT File Not Treated As MHT By IE

Aug 13, 2010

I have an MHTML file which has embedded images. The MHTML is generated on the server and then I will typically deliver the file using a BinaryWrite. I've also tried Server.Transfer, Response.Write after converting to ASCII and writing the file to disk and using a Response.WriteFile. In any of these cases the resulting file is not (it appears) treated as an mht file. For setting the image, I've tried Content-ID and Content-Location. The image URL shows up as cid:example1 when viewed in IE8. When opening up the file after saving to disk it shows up as mhtml:file://C:Documents and Settings enjynitoDesktopoutput634172401776447258.mht!cid:example1. Or while browsing with one of the methods that work you get [URL]

The Output.MimeType is message/rfc822. I've also tried application/octet-stream and multipart/related. Writing the file to disk and using a Response.Redirect works. Accessing the file with a direct URL works. Saving the file to disk and then opening the file works. It seems IE is assuming an HTML result to the request and not deciphering the new content type. But you can do things like this for dynamic style sheets, scripts, etc... so I don't really believe that. I couldn't see any glaring differences. I just tried and the BinaryWrite works fine in Opera. If I absolutely have to worry about writing to a temporary directory and then redirecting to the file I will. I was just hoping to avoid having to clean up the temporary files. Is what I want to do not possible? An example of writing the file is below.

if (response != null && response.Output != null)
{
Response.Clear();
Response.AddHeader("Content-Type", response.Output.MimeType);
Response.AddHeader("Content-Disposition", "attachment;filename=output" + DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture) + "." + response.Output.Extension);
// Response.Write( System.Text.Encoding.ASCII.GetString(response.Output.Bytes));
Response.BinaryWrite(response.Output.Bytes);
//Response.Clear();
//Server.Transfer("/ISV/Forms/Test/output634172397522707394.mht");
//Response.Clear();
//Response.WriteFile( Server.MapPath("/ISV/Forms/Test/output634172397522707394.mht"));
Response.Flush();
Response.End();

View 1 Replies


Similar Messages:

Web Forms :: File Upload Treated Differently In IE8 And FireFox 3.6

Dec 9, 2010

I've got a details view control, default set to Insert which I've added file upload controls. I've used a button to begin the upload process and add the other data to the database. The weird thing is that if I use FireFox to enter the data and upload the files, everything works fine but it works slightly differently in IE8. The difference is that when I browse for a file in FireFox, upload it and store the file name, it returns just the file name e.g. myPic.jpg. However, when I upload with IE8 it stores the entire route to the file e.g. C:/Users/Users/Site/myPic.jpg Why would a browser treat these things differently? And, is there a way to fix it to work on both browsers?

View 2 Replies

Web Forms :: File Download Using Response.BinaryWrite() - Odd Behavior

Jan 8, 2010

I am using a gridview to display (open or save) files that have been uploaded into a SQL 2005 server. I have a templatefield within the gridview that contains a linkbutton that does a postback to GetUploadedFile.aspx that then fires the response.binarywrite() code. The code seems to work fine and opens/saves the files correctly. But once this has completed and I try and click on another button on the page, instead of doing the appropriate action it re-fires the getuploadedfile.aspx binarywrite code and opens up the "Open/Save/Cancel" dialog again.

[Code]....

[Code]....

[Code]....

View 4 Replies

Response.BinaryWrite - Incorrect Name Of File Opened On A Client Side

Jan 24, 2011

[Code]....

The dilaogbox that offers me to save the file shows incorrect chars if documentFileName has name not in ASCII format. What I'm supposed to do to have the file name displayed correctly in this dialogbox and to have this file opened under the same name in MS Word, Excel whatever else?

View 5 Replies

Verbs Are Ignored And Treated As GETs?

Jul 21, 2010

I'm attempting to configure a webdav server example application [URL] to run on IIS6 (Win2003 Server). The application runs correctly on my dev machine (Win7, IIS7.5). When I attempt to map a drive to the DAV share, several requests are issued, including one OPTIONS request and two PROPFIND requests. In Fiddler, I see that these are transmitted correctly. However, the response is always the content of the default page on the site. If I look at the IIS logs, the requests are logged as GETs instead of OPTIONS or PROPFIND. UrlScan is disabled, but I went ahead and added OPTIONS and PROPFIND to the list of allowed verbs (since I'm running out of ideas).

View 1 Replies

MVC And Web Application Administrative Tasks - How It Will Be Treated

Jan 12, 2010

I am little bit confuse with Asp.net MVC Area.

When we talk about WebForms we say, for Administrative tasks, you must have an Admin folder to separate the admin task.

In MVC how i will treat my Admin tasks?

I will go for Admin Area or Admin Controllers,

Because if i will write controller for Admin tasks, each and every task will be written in one controller (AdminController) or if i will write Area -> Controller, means i will need to write at-least two controllers for each feature.

Second if we breaks the application in Areas (as modules) how i will manage Admin task for each Area.

View 1 Replies

ADO.NET :: Timestamp Wrongly Treated By LINQ / ASP As String

Feb 12, 2011

I was following a MSDN walkthrough [URL] which is a very simple ASP.NET example with Visual Studio 2010:

·
I have a simple database table with a timestamp column;

·
I created a "Linq to SQL Class", and drag the table from Server Explorer onto it;

·
I dragged a LinqDataSource onto the web page and pointed it to the dbml;

·
I dragged a DetailsView onto the web page using the LinqDataSource.

·
I enabled editing on the data source.

When I run, the time stamp column is also displayed on the DetailsView as something like "AAAAAAAAB9Y=". Then, when I change the "EmployeeName" and update, I got following exception: Failed to set one or more properties on type person. Cannot convert value of parameter 'tstamp' from 'System.String' to 'System.Data.Linq.Binary'. I was strictly following the MSDN walkthrough. I tried multiple times, I even installed Visual Studio 2010 SP1 Beta. But it consistently through this exception. Can someone shed some light on this? Not a encouraging start form someone thinking to learn the lastest Microsoft stuff!

I was following a MSDN walkthrough, which is a very simple ASP.NET website with Visual Studio 2010: I have a simple database table with a timestamp column;I created a "Linq to SQL Class", and drag the table from Server Explorer onto it;I dragged a LinqDataSource onto the web page and pointed it to the dbml;I dragged a DetailsView onto the web page using the LinqDataSource.I enabled editing on the data source.When I run, the time stamp column is also displayed on the DetailsView as something like "AAAAAAAAB9Y=".Then, when I change the "EmployeeName" and update, I got following exception: Failed to set one or more properties on type person. Cannot convert value of parameter 'tstamp' from 'System.String' to 'System.Data.Linq.Binary'. I was strictly following the MSDN walkthrough. Can someone shed some light on this? Not a encouraging start form someone thinking to learn the lastest Microsoft stuff!dfsaf

View 1 Replies

Error On Response.BinaryWrite PDF?

Feb 12, 2010

I am generating a pdf file to a MemoryStream, and then using Response.BinaryWrite to display that in the browser. But if a pdf reader is not installed, then I get an ugly error message.

Is there something I can do so that if no pdf reader is installed, I can display a friendly message or provide the option to save the file to the system?

View 2 Replies

C# - Response.BinaryWrite Gives Error On Production?

Dec 6, 2010

I'm using localReport to print PDF (SQL REPORTVIEWER). It works fine on localhost. When I move the application to Production (64 bits windows 2008) it gives me an error. (see below)

I put the renderedbytes in a Session in USERCONTROL and I do window.open('Program1.aspx')...

In page load of Program1.aspx I try to retrieve the Session variable and process.... I think this statement cause the error "Response.BinaryWrite (...) etc".

It works on my local pc (Vista 32bits)...

[Code]....

Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Code]....

View 2 Replies

Web Forms :: Extra Formatting With BinaryWrite Of PDF?

Oct 26, 2010

I have a server page generating a PDF file on the fly. I am currently submitting it to the client with a binarywrite. I would like to submit it formatted with the following "Adobe" options:

pagemode=thumbs

view=Fit

Is there any way to do this with a BinaryWrite? Or any way to do this in Javascript?

View 5 Replies

Response.BinaryWrite Not Working In Firefox And Chrome?

Dec 7, 2010

I have binary data - it is png picture.

I use Response.BinaryWrite to display this picture.

Unfortunately it works only in Internet Explorer. In Firefox and Chrome it shows long text of strange symbols.

What's wrong with BinaryWrite? How to solve this?

I may not say to asp:Image to show this picture, I may not indicate ImageURL, becouse there's no URL. This picture is response from webrequest. And webrequest may not be indicated in URL because I set some parameters not in QueryString but in post data.

View 2 Replies

Web Forms :: Add Redirect Button After Response.BinaryWrite

Feb 3, 2011

I need add a buttom to my aspx page.

My code is

byte[] buffer;
FileStream fs = new FileStream(@"C:info.pdf", FileMode.Open);
try
{

[Code]....

I need a click button after the code. How can I do this.

View 5 Replies

Web Forms :: W3wp.exe And Memory With BinaryWrite On Windows Xp 64bit?

Apr 26, 2010

My code reading a page from pdf file by PDFLib and sending it to client after putting watermark on the image. The problem is w3wp.exe posses is eating more memory in every request, so after using the program times the memory will be full. My Server system is windows xp 64bit.

This is me code:

[Code]....

Also I tried useing: Response.Buffer = False but no usefulness.

View 6 Replies

Web Forms :: BinaryWrite Image From Database Is Corrupt On Download?

Feb 18, 2011

We have been downloading Office 2003 documents stored in our database as images successfully using our ASP.NET 2.0 web portals. We recently started storing Office 2007 documents and though they upload without issue, the download and render does not work. The file opens with the error - "The file is corrupt and cannot be opened". It is only with Office 2007 files we see this. The web server supports the Office 2007 MIME types. We also apply the correct content-type when uploading a file to the database. Sample BinaryWrite code below. Is there something I am overlooking unique to Office 2007 files?

Dim MyData()
As
Byte
....
MyData = dreader("document")
....
Response.ContentType =
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
Response.AddHeader("Content-Length",
MyData.Length.ToString())
Response.AddHeader("Content-Disposition",
"attachment; filename=" & dreader("file_name").ToString)
Response.BinaryWrite(MyData)
Response.Flush()

View 10 Replies

Web Forms :: Automatic File Reading / Check For New File Everyday And If The New File Is In The Folder Read It

Sep 20, 2010

I would like ask you for some ideas how can I write mechanism that will be automatically read files from folder. I don't know how to schedule the write task. I want to check for new file everyday and if the new file is in the folder read it.

View 2 Replies

AJAX :: Attach A File Using File Upload Control And Send It In Email Along With Already Attached File

Apr 27, 2016

I have an asp.net panel having various controls including gridview. I have converted this panel into pdf and attached it as an email attachment using memory stream. Everything is working fine. Now I have an File upload control outside panel through which I have to attach a file and send it in mail along with the already attached panel. But I am unable to figure out how to do it.

View 1 Replies

Web Forms :: Controlling File Name Of The File Opened Directly From File Download Dialog?

Jul 26, 2010

I am downloading file from database using the following code. This code downloads an excel file from the database which has a macro attached to it when it is opened. This macro reads file name of the excel file and uses it for its computation. Everthing works file if user saves the file on his harddisk and then open if but if he directly opens the file from the dialog(by hitting 'Open' button) then file name of the opened excel file comes out be the name of the webform that has the above code and this leads to error in the macro. Is there any option through which i can control the name of the file if user directly opens the file from dialog or the option to disable or remove 'Open' button form the dialog?

[Code]....

View 2 Replies

How To Get Posted File From Upload File Or Html In Put File

Feb 2, 2011

my project is in c sharp and must upload pictures to MySql DataBasethe uploadfile controle is included in asp form that i made but the problem is that the uploadfile always get the Postedfile = null i tried to use html input file but the same problem still
@ Page Language="C#" MasterPageFile="~/MasterPageB.master" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Add_Pictures" Title="Untitled Page" %>
<%@&nbsp;MasterType&nbsp;TypeName="MasterPageB"&nbsp;%>
<%@&nbsp;Register&nbsp;assembly="MyFormView"&nbsp;namespace="MyFormView"&nbsp;tagprefix="asp"&nbsp;%>
[code]...

View 1 Replies

AJAX :: Async File Upload Control - Check File Contenttype Before File Upload Starts?

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

Web Forms :: To Get Filename And File Path Using HTML File Control In Aspx Page?

Jan 6, 2011

I am using HTML file control and HTML image control in .aspx page (for uploading image and showing on web page). It is working fine. But I am unable to get that uploaded image file path and file name in .aspx.cs page. And also tell me how to save selected image in MS ACCESS database.

View 4 Replies

How To Copy File From Client Machine To Server Folder Without File Upload Control

Mar 25, 2010

I have to copy a file from client machine to server folder without use file upload control.

i tried with WebClient().Like this

Dim onbjweb As New WebClient()
onbjweb.UploadFile(Server.MapPath(serverpath), "POST", LocalFilePath).

Its working fine in localhost.When its deployed in server its not working.

View 2 Replies

Jquery - JSON Can Call Method In .aspx File But Not In .asmx (web Service) File

Jul 3, 2010

I am using JQuery & JSON (POST) to call webmethod. However I can call only webmethod located at aspx file but not in asmx file Below are sample codes

CustomValidate.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Public Class CustomValidate
Inherits System.Web.Services.WebService
'ACCESS VIA JSON
<System.Web.Services.WebMethod()> _
Public Shared Function AJAX_Test(ByVal date1) As Boolean...
Return True
End Function
End Class
Javascript: JQuery JSON
function isDates(source, arguments) {
var isValidDate;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CustomValidate.asmx/AJAX_Test",
data: '{date1: "' + arguments.Value + '"}',
dataType: "json",
async: false,
success: function(result) {
isValidDate = result;
},
error: function(httpRequest, textStatus, errorThrown) {
alert("status=" + textStatus + ",error=" + errorThrown);
}
});
arguments.IsValid = isValidDate;
}

It always return javascript undefined error. But if I put the AJAX_Test webmethod in aspx page and replace the url: "CustomValidate.asmx/AJAX_Test" to "mypage.aspx/AJAX_Test". It works fine.

View 1 Replies

Configuration :: Web Confg File And File In Project For Sending Error Message Email

Jan 17, 2011

I am trying to configure my web application to send emails to my email address in case of any error . Below is my coding in the web config file, I am following example from a book cuase I AMM A nOVICE TO VISUAL STUDIO AND .NET AND C#. THE NAME OF THE BOOK IS ASP.Net E-Commerce in C#. I am not sure what to put in for the MailForm value since the book did not say could someone tell me .

[Code]....

In my other configuration file under the App_Code folder I have this coding Below:

[Code]....

View 1 Replies

C# - Why Does Copying A File Using FileInfo.CopyTo Creates The Destination Copied File As Readonly

Jun 11, 2010

I have two folders in my asp.net web application in which I create new folders programmaticaly. The entire solution is under VSS source control. I was not able to manipulate these two folders programmably. For that, I gave {MACHINE}ASPNET user account full control over these two folders. Still, the "access denied to the path" error was coming. I saw that these entire folders were marked readonly. I tried to uncheck Readonly from explorer but not successfull, readonly check does not get removed. Also, if I copy files using method, the destinationn copied file becomes readonly. I have also tried File.SetAttributes (path,FileAttributes.Normal); but no success. How can I make the copied file not READONLY?

View 1 Replies

SQL Server :: Importing .SQL File Into .MDF Database File Created By Visual Web Developer Express?

Dec 15, 2010

I am trying to import the SQL file provided by Elmah into my application, and I don't want to import it into the development machine I use. I want to make it a .mdf file so it can be easily transported to my host. I was wondering if there is a way to do this?

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved