C# - Keeping Alive PostedFile.InputStream ?

Jan 21, 2010

I was wondering wich's the best way to "keep alive" the InputStream of the FileUpload Control.I would give you one example. Let's assume you have the FileUpload control in one WebForm, and you want process it in the next WebForm (after Response.Redirect).It would be great (unless for the memory) to have something similar to:

Session["PostedFile"] = this.FileUpload.PostedFile.InputStream.
Unfortunately, this results in:
System.ObjectDisposedException

View 2 Replies


Similar Messages:

Web Forms :: Maintain FileUpload.PostedFile.InputStream Value To Different Pages

Dec 20, 2010

I am working on FileUpload. I have sequence of forms showing in popup, In the starting form i am uploading the file and i have to get the PostedFile.InputStream at the end of the form. I am navigating the all form values until last form, but i am not able to get the PostedFile.InputStream value. Once page refreshed the fileupload control value is clearing. how can i get it until end of the form.

View 3 Replies

C# - Leaving A BinaryReader Object Un-disposed In Order To Keep Request.InputStream Alive?

Feb 1, 2011

I have a couple methods to handle the saving of an image using Request.InputStream. I have two extensions that share the HttpContext. In one of my methods, I'm using a BinaryReader to read in the contents and do the processing. However, naturally, when disposing the BinaryReader, it closes off the InputStream property on Request. My SECOND method uses the same input stream to create a thumbnail.

Bascially, I need a way to keep the Request.InputStream property alive after disposing the reader in the first method. Is this possible? Here are my two methods. SaveImageStream() is called first, then GenerateThumbnail().

[Code]....

View 2 Replies

AJAX :: Keeping Session Alive Via Webservice?

May 21, 2010

if updating a session value from within a webmethod call made from jquery would be able to keep my session alive?

JS:

$.ajax({
type: "POST",
url: "MyWebService.asmx/Keepalive",
async: true, [code]....

View 1 Replies

Open A New Window Whilst Keeping The Old One Alive?

Feb 14, 2011

I gather customer information on a asp.net page (.net 2.0) then I want to open a new page / window which will be passed all the payment details and then connect to our payment service provide to process the payment. Once done the payment window is then close and the original calling window is updated with the result of the payment.

I can do all of the above, except I don't know how to go about opening a 2nd IE window leaving the calling windows on the screen whilst passing parameters and retrieving the result.

My best guess would be:-

Stuff all the parameters into session state var's

Open a new windows / page pickup the session state var's

Process the details

Write the results back to session state var's

Close the new window

Pickup the results from the session stae var's

View 3 Replies

Keeping .NET Session / Forms Authentication Alive In Silverlight Application?

Sep 13, 2010

I have a web app containing a silverlight application. How do I keep the ASP.NET session / Forms Authentication alive when the user is using the silverlight application?

View 1 Replies

.net - Htmlinputfile.postedfile Is Nothing?

Feb 24, 2011

I have the following form page (aspx)

<form id="form1" runat="server" enctype="multipart/form-data" method="post">
<forms:FormDisplay ID="UserProfileForm1" runat="server" />
</form>

The UserProfileForm1 control is a form builder that creates a form based on the profile design. When the form is posted, I am looking through the controls in the form and handling each one as needed. We there is a file upload control it shows up as a htmlinputfile control but the postedfile property is always nothing.When I look at the Request.Files collection the first file (Request.Files(0)) is the file I selected to upload. Why is this not being mapped back to the control under .postedfile?I have a control builder which uses the following code to create the control

Dim file As New HtmlInputFile
file.ID = "fil" & md.DataID & md.Name
Return file

View 1 Replies

Writing Mp4 File From Request.InputStream?

May 28, 2010

I have a page posting data to me via HTTP POST. What i want is write posted data into mp4 video format file. Here my code how to write that file:

string strFilePath = "D:\Video.mp4";
using (FileStream fs = new FileStream(strFilePath, FileMode.Create))
{
byte[] bytes = new byte[Request.InputStream.Length];
Request.InputStream.Read(bytes, 0, (int)Request.InputStream.Length);
fs.Write(bytes, 0, bytes.Length);
}

My problem is that i got the file, but it's corrupt when playback. Is there any problem with my stream or i missing some decode for mp4 file?

View 2 Replies

Reading InputStream Into Byte Array

May 21, 2010

[Code]....

My fu.PostedFile shows data in it. Each index of the array has different value in it. But arrFileByte shows all the index have 0 as their value. I've used this very code to upload files in the database before. What might be the resaon it is not working now.

View 6 Replies

C# - Change HttpContext.Request.InputStream

Apr 19, 2010

I am getting lot of errors for HttpRequestValidationException in my event log.

Is it possible to HTMLEncode all the inputs from override of ProcessRequest on web page. I have tried this but it gives context.Request.InputStream.CanWrite == false always.

Is there any way to HTMLEncode all the feilds when request is made?

public override void ProcessRequest(HttpContext context)
{
if (context.Request.InputStream.CanRead)
{
IEnumerator en = HttpContext.Current.Request.Form.GetEnumerator();
while (en.MoveNext())
{
//Response.Write(Server.HtmlEncode(en.Current + " = " +
//HttpContext.Current.Request.Form[(string)en.Current]));
}
long nLen = context.Request.InputStream.Length;
if (nLen > 0)
{
string strInputStream = string.Empty;
context.Request.InputStream.Position = 0;
byte[] bytes = new byte[nLen];
context.Request.InputStream.Read(bytes, 0, Convert.ToInt32(nLen));
strInputStream = Encoding.Default.GetString(bytes);
if (!string.IsNullOrEmpty(strInputStream))
{
List<string> stream = strInputStream.Split('&').ToList<string>();
Dictionary<int, string> data = new Dictionary<int, string>();
if (stream != null && stream.Count > 0)
{
int index = 0;
foreach (string str in stream)
{
if (str.Length > 3 && str.Substring(0, 3) == "txt")
{
string textBoxData = str;
string temp = Server.HtmlEncode(str);
//stream[index] = temp;
data.Add(index, temp);
index++;
}
}
if (data.Count > 0)
{
List<string> streamNew = stream;
foreach (KeyValuePair<int, string> kvp in data)
{
streamNew[kvp.Key] = kvp.Value;
}
string newStream = string.Join("", streamNew.ToArray());
byte[] bytesNew = Encoding.Default.GetBytes(newStream);
if (context.Request.InputStream.CanWrite)
{
context.Request.InputStream.Flush();
context.Request.InputStream.Position = 0;
context.Request.InputStream.Write(bytesNew, 0, bytesNew.Length);
//Request.InputStream.Close();
//Request.InputStream.Dispose();
}
}
}
}
}
}
base.ProcessRequest(context);
}

View 1 Replies

Upload Postedfile Lost During Postback?

Mar 29, 2010

I am using an asp:upload control to upload an image and am using the postedfile property to insert the path to the database. In my form I have a dropdown with autopostback=true where the user can select a topic to populate a checkbox list of categories. During that postback, the postedfile value is being lost and after a little research I have discovered that the posted file value is not maintained in viewstate for security reasons.

View 4 Replies

Web Forms :: PostedFile.ContentType Value For .txt Or .csv File?

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

How To Read Inputstream From HTML File Type In C# Without Using Server Side Control

Sep 17, 2010

I have the following form

<form id="upload" method="post" EncType="Multipart/Form-Data" action="reciver.aspx">
<input type="file" id="upload" name="upload" /><br/>
<input type="submit" id="save" class="button" value="Save" />
</form>

When I look at the file collection it is empty.

HttpFileCollection Files = HttpContext.Current.Request.Files;

How do I read the uploaded file content without using ASP.NET server side control?

View 2 Replies

Web Forms :: PostedFile.FileName Not Returning Full Path?

Jan 20, 2011

i have a file upload control as below:

<input id="txtLocalResource" style="width:100%" type="file" size="16" name="txtLocalResource" runat="server">

in my code when i look at txtLocalResource.PostedFile.FileName it returns only the filename, the rest of the path is missing? i am using ie8 and vs2010.

View 4 Replies

Web Forms :: MyFileInput.PostedFile.ContentType Equals Null?

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

Web Forms :: FileUpload PostedFile Gives NULL Reference Exception

Jul 9, 2012

This is my button event code

protected void ImageButton2_Click1(object sender, ImageClickEventArgs e)
{
string data = Server.UrlDecode(Request.QueryString["BehCode3"]);
string filename = System.IO.Path.GetFileName(fup1.PostedFile.FileName);
string filename1 = System.IO.Path.GetFileName(fup2.PostedFile.FileName);
string filename2 = System.IO.Path.GetFileName(fup3.PostedFile.FileName);

[Code]...

View 1 Replies

AJAX :: ASyncFileUpload UploadedComplete Event - Saving The PostedFile.filename Value?

Feb 14, 2011

I have the asyncFileUpload control inside a user control which is a wizard control step. The wizard control is inside a AJAX update panel.

I have a requirement to save the complete folder path along with the file name when user selects a file in the asyncFileUpload control. In order to achieve this on the server side UploadedComplete even I save the PostedFile.FileName to a session variable.

Then on the client side OnClientUploadComplete I force a postback for the UpdatePanel. In the postback I get session variable value and then do my processing.

server side upload completed event when I save the posted file name to a session variable. This is working in my local machine. I am able to retrieve the Session variable on the postback, but when I move the code to my test server the Session value is coming out as blank. I validated that the UploadedComplete event is triggered on the server, but for some reason the Session value is blank.way I can get the PostedFile name (complete path) on the Client side?

View 1 Replies

Forms Data Controls :: UpdateParameters / FileUpload1.PostedFile.FileName?

Oct 27, 2010

I have the following code in my UpdateParameters in a ListView

<UpdateParameters>
<asp:Parameter Name="MenuThumbImage" Type="String" />
</UpdateParameters>

And I'd like to update it to the value of FileUpload1.PostedFile.FileName I have this in a variable in the aspx.vb page as myFileName How would I use that value in the UpdateParameters section?

View 6 Replies

How To Keep Connection Alive When Using Webrequest

Mar 8, 2011

string strURL = (Request.IsSecureConnection ? [URL] : [URL]

[code]....

I get an error on da line objPost.Close();.....the unusual error is that when I debug this code line by line slowly using F10 in visual studio 2010...the code works..but when I just run the program or even debug the program fast...it throws an error at that line.. it gives an error that the connection which was expected to be open was closed by the server..

View 1 Replies

VS 2005 Automatically Redirect To Alive URL

Apr 21, 2010

I have a web application running from 2 servers. I'm using 2 servers, because if 1 is not responding for any failure user can access the application from other server URL. Now I want to do the redirection automatically. That means, user will enter the URL of the primary server if it is not responding then it will automatically redirect to the other server URL. How can I do that using ASP.NET and C#?

View 5 Replies

State Management :: Want To Keep Session Alive?

Jan 18, 2011

i have a website where i want to keep the session alive while user has browser open?

View 9 Replies

C# - TCPClient Seems To Not Maintain A Keep-alive Connection?

Jul 5, 2010

I have the following code using the TcpClient

byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("username" + ":" + "password");
string follow = "track=soccer,twitter";
byte[] encode_follow = System.Text.Encoding.UTF8.GetBytes(follow);

[code]...

View 1 Replies

Web Forms :: Error - Web.UI.WebControls.Button Does Not Contain A Definition For HasFile, FileName, SaveAs And PostedFile

Dec 23, 2010

In my file upload file I am getting Web.UI.WebControls.Button does not contain a definition for HasFile, FileName, SaveAs and PostedFile.

The code I am using is:[Code]....

View 12 Replies

How To Keep Session Alive Between Two Calls To A Web Service In A C# Application

Oct 5, 2010

This is quite straight forward. I'm calling a web-service (.asmx, with session enabled) from a c# application. I want each call to be with the same session key as the previous one (as opposed to creating a new session key each time).

Here's my (nothing-out-of-the-ordinary) code:

[Code].....

View 3 Replies

WCF / ASMX :: Keep Object Alive On Server In Service

Nov 19, 2010

I have to keep a datacontext alive in a WCF service. This object is created on every call to the service, by the way decreasing performance. How could I keep this object alive with WCF.

View 2 Replies







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