MVC :: Unable To Remove The Cookie From The Response Stream After Reading It?

Sep 29, 2010

I am trying to use a custom ITempDataProvider provider to store TempData in a browser's cookie instead of session state. However, everything works fine except that I am unable to remove the cookie from the Response stream after reading it. The code exexutes fine but the cookie won't go away.

[Code]....

And in my controller:

[Code]....

View 6 Replies


Similar Messages:

Save A File / Stream To Local Folder From Response Output Stream?

Feb 22, 2011

I have an excel file in my Response Output stream. I can Open the stream as a file after a prompt, but it doesn't seem I can save it directly to a specified folder on my client.

View 1 Replies

State Management :: Remove Item (Cookie) From Basket (Cookie Collection)?

Sep 8, 2010

I am busy building a shopping cart with cookies. I have datalist which I populate from the cookies with a delete button next to each cookie

[Code]....

Now the problem is that when I hit the delete / remove button to expire the cookie, what happens when repopulating the datalist is that it shows the original cookie with all it's values as well as a new entry where all the values are blank.

View 3 Replies

C# - Reading Stream And Open That Document?

Oct 15, 2010

I have a stream object in which I have some document, I know what document is it, how can I open that document without saving it into a file physically. So I want to directlly open the document from stream itself without saving it.How to do that? I doing it in c#

View 4 Replies

Web Forms :: Reading A File Into Stream And Saving It To A Location?

Oct 8, 2010

I have a third party CMS system that can create forms but can't manage true File upload capabities. I am able to get users brows for thier file and have the value submited to my custom .net code behind page for processing. So I end up with like "C:somefilefoldersomefile.doc".

But on my processing page I want to read this file (like the file uploader) and save it to a location. I tried using the file uploader control (but have it not visible) but realized I can't preset it as I was planning to set it and do the normal processing from there. Is there another way to do this?

View 3 Replies

HttpHandlers / Modules :: Reading Video From Byte Stream Using Handler?

Jan 1, 2011

i have a application which use to store video in sql databasei want to have a function which should have return type of video so that i can pass it to player in next page, for that i have retrived it as byte stream but dont know how to return it as video file.if i am going wrong then suggest me some other way.Note video are based on authentication so no way to switch to file system

View 1 Replies

C# - Return XML To The Response Stream?

Nov 10, 2010

I'm trying to return an xml string from a IHttpHandler to a like this: context.Response.Write(xml); When I receive the response in my .aspx.cs I try to load the document as follows: var xml = XDocument.Load(xmlString); but I get an Illegal Characters in Path error message. I've also tried

context.Response.Write(context.Server.HtmlEncode(xml));

and

var xml = XDocument.Load(Server.HtmlDecode(xmlString));

but I get the same message. Is there any way I can return XML from my IHttpHandler?

View 3 Replies

C# - Convert Response Stream To An Image?

Aug 29, 2010

in previously asked question answeres said they dont get what i want to do exactly so heres is the full code also i simply want that instead of a TABLESe i rendered an image( of the content ) on the page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Text;
using System.Data;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.WebControls.Panel panelmain = new System.Web.UI.WebControls.Panel();
System.Web.UI.WebControls.Literal abc = new System.Web.UI.WebControls.Literal();
abc.Text = "as<br/>dasdas<br/>dasdad";
DataSet ds = new DataSet();
DataTable dt;
DataRow dr;
DataColumn idCoulumn;
DataColumn nameCoulumn;
dt = new DataTable();
idCoulumn = new DataColumn("ID", Type.GetType("System.Int32"));
nameCoulumn = new DataColumn("Name", Type.GetType("System.String"));
dt.Columns.Add(idCoulumn);
dt.Columns.Add(nameCoulumn);
dr = dt.NewRow();
dr["ID"] = 1;
dr["Name"] = "Name1";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = 2;.............

View 1 Replies

C# - Render Response Stream With Jquery?

Jan 9, 2010

MemoryStream export = new MemoryStream();
iCalendarSerializer serializer = new iCalendarSerializer(iCal);
serializer.Serialize(export,System.Text.Encoding.UTF8);
return export;

so I am using the C# DDay.iCal library for exporting my calendars. Serialize takes in a "stream" so I passed it a memory stream. I now have a generic handler that calls the method that contains the above code.

public class CalendarHandler : IHttpHandler
{
private Calendar service;
private Membership membershipS;
public void ProcessRequest(HttpContext context)
{
service = new Calendar ();
membershipS = new Membership (null);
string userName = context.User.Identity.Name;
Guid userId = membershipS.GetUsersId(userName);
context.Response.ContentType = "text/calendar";
// calls the export calendar(the code that showed above that uses dDay ical.
var t = service.ExportCalendar(userId);
t.WriteTo(context.Response.OutputStream);
}
public bool IsReusable
{
get
{
return false;
}
}
}

So now I wrote the icalendar to the Outputstream. Now I have a jquery post that goes to this method and now I am not sure how to take the OutputStream result that the jquery post will get and make it popup with a save dialog box.

$('#ExportCalendar').click(function(e)
{
$.post('../Models/CalendarHandler.ashx', null, function(r)
{
});
return false;
});

View 2 Replies

Insert Anywhere A String Into The Response Stream?

May 7, 2010

I created a simple Http Module that starts a timer on the PreRequestHandler and stops the timer on the PostRequestHandler to calculate the time it took the page to load. I then create some simple html and write my results to Response.Write. Since I'm doing this in the PostRequestHandler it's adding my results after the </html> tag. That's fine for testing but I need in a scenario where the page needs to validate.

I can't seem to figure out how I could manipulate the Response object to insert my results before the </body> tag. Response.Write and Response.Output.Write don't have that flexibility and I couldn't see a way to work with the Response as a string. Am I missing something easy?

View 1 Replies

C# - Create A BitmapDecoder Off .Net Response Stream?

Dec 6, 2010

We're getting this weird exception when trying to create a BitmapDecoder off an ASP.Net response stream. This is the line of code that throws the exception:

BitmapDecoder dec = BitmapDecoder.Create(
Request.Files[0].InputStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.OnLoad);

Here's some info on the file being uploaded: Filename: bank statement.jpg, Content length: 266041, Mime type: image/jpeg

This is the exception stack trace:

System.IO.IOException: Cannot read from the stream. --->
System.Runtime.InteropServices.COMException (0x88982F72):
Exception from HRESULT: 0x88982F72 [code]...

how we can prevent this from happening?

View 1 Replies

MVC :: Error Reading Cookie With Associated Path

Nov 19, 2010

I'm seeing some weird behavior within MVC 2 in regard to reading cookies. I write a cookie and specify a path. I intermittently see a null value returned for this cookie within my MVC application. I've verified throug Firebug that the browser is sending along the cookie in the request headers. When debugging, I can see the cookie in the headers (i.e.) Request.Headers["cookies"] but when trying to access the cookies collection, it's null (Request.Cookies["mykey"].

I'm using the AsyncController. Since this the issue is intermitent, is it possible there is a race condition?

View 1 Replies

Update Image Based On Response Stream?

Sep 20, 2010

Is is possible to update an image on an HTML page using the response stream of an ASP.NET Generic Handler? For example, if I have the following code on a handler: [URL]

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "image/png";
context.Response.WriteFile("~/images/test.png");
}

How can I call the handler in jQuery, using .ajax, and set an image on the page equal to the image that is returned by the Handler? I am ignoring the query string variable at the moment as I just want to get this working. Secondly, if I can do above, how can I loop through all of DIVs on the page that are of class "content", select a guid out of a hidden field to use as my query string parameter, and update the associated image within the same content DIV tag? A content div tag would look as follows:

<div class="content">
<asp:TextBox runat="server" Id="HiddenField_1" Value="C142E68F-B118-4565-9A9E-B2347F0B6D5B"/>
<img src="#"/>
</div>
<div class="content">
<asp:TextBox runat="server" Id="HiddenField_2" Value="GJ38AD23-B118-4565-9A9E-B2347F0B6D5B"/>
<img src="#"/>
</div>

I would like to have all the images updated on a periodic interval, so essentially, as a quick recap, I would need to have: A loop through all of my DIVs of class "content", occuring every n. seconds. Extractation the GUID from the hidden field. A call to my ASHX handler to get the updated image. Set the returned image to the corrisponding image on the page. Is this something that would be difficult to achieve? If not, what would I need to do to make this function in the above manner?

View 1 Replies

C# - Response.WriteFile - Write Out A Byte Stream

Sep 21, 2010

Is is possible to write to the http response stream from a dynamically created bitmap using the Response.Write/WriteFile without saving the image to the hard drive?

View 4 Replies

Web Forms :: Reading Multiple Values From Cookie

Feb 23, 2010

I have set in one condition

Response.Cookies["mycookie"]["value1"] = string1;
Response.Cookies["mycookie"]["value2"] = string2;

c# code for reading these values to two string variables, str1 and str2.

View 2 Replies

Architecture :: How To Handle An Excel Stream And The Http Response

Jan 27, 2011

I'm using .net 3.5 and am currently creating a web application used to generate a report through Aspose.CellsActually, the page is composed in a form where I get the configuration of the report I have to generate. The "generation" button is in an update panel. When I click on it, the "generation" button is hidden and a progress bar appears. When the excel file is generated, I save it in a memory stream and I send it back to the aspx page where I change the headers to allow the file's download.

View 3 Replies

Examine WebResponse Without Affecting The Underlying Response Stream In .NET?

Oct 27, 2010

After a call to initial HttpWebResponse.GetResponseStream() and reading through the stream, that stream is done for and cannot be reused.

I have a situation where I need to examine the content of the response and if it is of a certain data, get another page and then pass the new response down the line. Otherwise, pass down the original response as is. The only problem is that after examining the response to check for this "special data", that response is no good to the downstream code.

The only way, I can think of, to make this transparent to the downstream code, is to create a derived class of HttpWebResponse, and somehow cache the data streamed, and pass that cached stream down the line instead of the initial stream. I'm not sure if that's even feasible since I haven't looked into it further.

View 3 Replies

Web Forms :: Send A Large File To The Response Stream - OutofMemory?

May 20, 2010

I'm using Filestream for read big file (> 500 MB) and I get the OutOfMemoryException. Any solutions about it?? I want this in my app asp.net: Read DATA from Oracle Uncompress file using FileStream and BZip2 Read file uncompressed and send it to asp.net page for download. When I read file from disk, Fails !!! and get OutOfMemory. My Code is:

using (var fs3 = new FileStream(filePath2, FileMode.Open, FileAccess.Read))
{
byte[] b2 = ReadFully(fs3, 1024);
}
// [URL]
public static byte[] ReadFully(Stream stream, int initialLength)
{
// If we've been passed an unhelpful initial length, just
// use 32K.
if (initialLength < 1)
{
initialLength = 32768;
}
byte[] buffer = new byte[initialLength];
int read = 0;
int chunk;
while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
{
read += chunk;
// If we've reached the end of our buffer, check to see if there's
// any more information
if (read == buffer.Length)
{
int nextByte = stream.ReadByte();
// End of stream? If so, we're done
if (nextByte == -1)............................

View 8 Replies

HttpHandlers / Modules :: Write The Response Stream Content To A File On Disk

Jan 20, 2011

I have an httpmodule and it has a handler for OnEndRequest. I am trying to write the HttpContext.Response.OutputStream to a file. I am trying to use the Read method of it. But when it is called the exception message i get is "Specified method is not supported". So i am not able to do what i want that is, write the response to a file on the disk. I am able to write the HttpContext.Request.InputStream to a file using its Read method which i do in a handler for OnBeginRequest.

View 2 Replies

Javascript - Response Object Not Returning Excel Stream In Update Panel?

Oct 11, 2010

I am generating an Excel file upon a click of a button in an update panel. It is throwing a parsing error.

If I keep the button outside the update panel it is working fine. Why isn't it working in the update Panel?

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition",
String.Format("attachment;filename={0}", filename))
Response.Clear()
Response.BinaryWrite(WriteToStream.GetBuffer)
HttpContext.Current.ApplicationInstance.CompleteRequest()
Private Function WriteToStream() As MemoryStream
'Write the stream data of workbook to the root directory
Dim file As MemoryStream = New MemoryStream
hssfworkbook.Write(file)
Return file
End Function

View 1 Replies

Remove Cookie From XMLHttpRequest Object?

Jun 23, 2010

I am making an ajax call with jquery like:

$.ajax({
url: "path/to/webservice.asmx"
beforeSend: function(xmlHTTPRequest) {
//modify headers here
//remove cookies
}
success: function() {
//do stuff
}
}

What I would like to do in the beforeSend function is take the incoming xmlHTTPRequest variable that is set and modify the headers to remove the cookie object that is in there, so in the call to my web service, it does not renew forms authentication in asp.net

View 1 Replies

Jquery - How To Write A File To The Response Stream And Have A 'Working' Modal Window Show/hide

Feb 15, 2011

I need to to export a file to the user. It takes 1-2 min to generate the file so I'd like to have the page go into a kind-of modal mode with a layover on the page and a 'Working' spinner showing. The problem is I can't make the modal stuff go away after Save File dialog is closed.

How can I remove the layover after the dialog is done?

View 1 Replies

Why Is Cookie Available In Request Immediately After Setting Using Response

Aug 4, 2010

In pageload, if you do Response.Cookies.Add(..., immediately in the next line, you can access that cookie via Request.Cookies(... I know that under the covers, the cookie is added to Request.Cookies by .net, but the original request never had that cookie.

If what I'm saying is correct, why is it this way? Shouldn't the cookie be available in the following request? Shouldn't the immediate access to Request.Cookies(... be null?

View 1 Replies

Web Forms :: Set Cookie In Response Not Coming Back Through Request

Jul 6, 2010

My web site is integrated into a client web site. Client web site reaches out to my site through an Xml request and I return Html embedded in an Xml response. Client site then displays the Html in an area on a page on their site. All is well so far...

Now, there is a link on the Html that does an HttpPost back to my site which causes a re-direct to another page on my site. i.e. [URL] -> HttpPost -> [URL]-> Response.Redirect("CookieTest.aspx"). Still, all is well. [URL]

All of the above can occur without authentication to mysite. Where I start running into problems is when CookieTest wants to do a FormsAuthentication.SetAuthCookie(). If I put a button on CookieTest that does FormsAuthentication.SetAuthCookie() and then Response.Redirect("SecurePage.aspx"), still under [URL], the SecurePage does not recognize the authentication because the auth cookie is not present.

1. Navigate straight to CookieTest.aspx

So I simplfied the problem into basic cookie set/read excercise and used the code below to test out cookie writing/reading ability. When I call the page directly from the browser I see that on initial load the response cookies are empty. Then on button click I see that the cookie is properly set in the response. Then on subsequent page refresh I see that the page load shows the request cookie.

2. Navigate to CookieTest.aspx in an HttpPost from [URL], as mentioned above.

Now on button click I see the cookie in the Response but do not see it come back in the Request of subsequent page refreshes, as if the client browser is rejecting cookies set by my server.

3. Navigate straight to CookieTest.aspx, then do the HttpPost from [URL]

In this case, since the cookie was set during a straight navigation to CookieTest.aspx, the cookie is present in the subsequent HttpPost/Redirect from [URL]. CookieTest.aspx has full access to the cookie and can even delete it.

4. Have CookieTest.aspx pop a new browser window simply sets the cookie and closes itself down.

Similar to #3, if the cookie is set through a popup window and then CookieTest is refreshed the cookie is present in the Request.

Notes:

The code does prove that the client browser accepts cookies.

When my page (CookieTest.aspx) is shown within the frame on the [URl] page, during any link back to my server, the Request.Url.Host shows my domain.

[code]....

View 3 Replies

MVC :: Reading Views Response In Controller Actions?

Feb 2, 2010

I am trying to read the response of ResultView in the action of some controller. I need to process the response before returning the ResultView. I am trying the following code:

[Code]....

Whenever I read writer, I get empty string though no exceptions occur.

View 4 Replies







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