NULL Value Exception When Trying To Save To Stream
Sep 23, 2010
Im trying to resize an image. I have the original file and then try to resize it and save it to a new image.However, I get an exception because the value of stream cannot be null. This makes sense, but I dont know how to prevent it:
Value cannot be null.
Parameter name: stream
Description: An unhandled exception occurred during the execution of the current web request.
Source Error:
[Code]....
View 30 Replies
Similar Messages:
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
Apr 26, 2010
I have a form that streams a pdf to the browser. That works fine, the problem is when the user clicks the "save" button on the PDf that has been streamed, it saves the .aspx page! as to how I can set it to default to .pdf?
View 6 Replies
Sep 1, 2010
I'm getting a null reference exception whenever I try to databind this datatable to the Gridview. I know for sure that the datatable has data. I've checked it.
[Code]....
I get the error when it gets to the last line here..
View 8 Replies
Apr 2, 2010
I'm making tests with ASP.NET HttpHandler for download a file writting directly on the response stream, and I'm not pretty sure about the way I'm doing it. This is a example method, in the future the file could be stored in a BLOB in the database:
public void GetFile(HttpResponse response)
{
String fileName = "example.iso";
response.ClearHeaders();
response.ClearContent();
response.ContentType = "application/octet-stream";
response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
using (FileStream fs = new FileStream(Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), fileName), FileMode.Open))
{
Byte[] buffer = new Byte[4096];
Int32 readed = 0;
while ((readed = fs.Read(buffer, 0, buffer.Length)) > 0)
{
response.OutputStream.Write(buffer, 0, readed);
response.Flush();
}
}
}
When I open the url with the browser, appears the "Save File" dialog... but it seems like the server has started already to push data into the stream before I click "Save", is that normal? If I remove the line"response.Flush()", when I open the url with the browser, ... I see how the web server is pushing data but the "Save File" dialog doesn't come up, (or at least not in a reasonable time fashion) why?
When I open the url with a WebRequest object, I see that the HttpResponse.ContentLength is "-1", although I can read the stream and get the file. What is the meaning of -1? When is HttpResponse.ContentLength going to show the length of the response? For example, I have a method that retrieves a big xml compresed with deflate as a binary stream, but in that case... when I access it with a WebRequest, in the HttpResponse I can actually see the ContentLength with the length of the stream, why? What is the optimal length for the Byte[] array that I use as buffer for optimal performance in a web server? I've read that is between 4K and 8K... but which factors should I consider to make the correct decision. Does this method bloat the IIS or client memory usage? or is it actually buffering the transference correctly?
View 4 Replies
Sep 6, 2010
How to save stream as image and store the image in temp files?
View 4 Replies
Apr 29, 2010
I have a TextArea html helper method I'm calling in a foreach loop. Basically, when I initially load the View it works fine, but when i reload the View and load postback data, the same TextArea throws a NullReferencException and yet the variable I'm using in the TextArea as the name of the TextArea is not null. I've attached a picture below for demonstration:
if it's difficult to see, the blue arrow below is pointing to the variable used to name the TextArea. Again, it works on initial load, but it errors out on postback when the page is reloaded. I'm not sure what's going on.
View 2 Replies
Jul 15, 2010
I am getting this exception even though no values to my knowledge are null, apart from the model.SuburbID itself.
Here is controller code for getting the suburbs:
[Code]....
Here is the view code:
[Code]...
View 3 Replies
Jan 19, 2010
My controller calls a class in my model which is getting data from a REST web service. The class in the model then passes the data back to the controller using an IList, like so:
[Code]....
My problem is this: The data that is held in the IList isn't there until the user has done a search in the View, submiting a form. This is a basic search function with 2 textboxes and a submit button in a form. When the user clicks submit, the controller action is called, the web service is then called, and the data in the IList gets populated. The problem is that in the View I am using a strongly typed view and my model reference in the foreach loop throws a Null Reference Exception because there is no data in it, because a search has not been conducted yet...
[Code]....
So, how can I have the above foreach loop in my view if there isn't any data in the model until a search has been conducted? Is there a better way that I should be doing this?
Essentially, what's the best method for passing data back to a view that is based on a form submittion?
View 6 Replies
Dec 6, 2010
We have a chart on a page that current is hard coded with test data, client likes and we are trying to now link to live data.I have tried different things in the code behind to build the url and keep getting Null Reference Exception even though when i debug the url is there and complete. I can take the value that i get in debug and paste directly to the browser and the chart works. so i know that im building the url correctly, but setting the .Src of the image in the page_load event doesnt seem to be the correct way to populate the image..Here is the complete link that is built in the code behind that is passed to the src of the image control.http://chart.apis.google.com/chart?hs=300x265&chd=s:bD&chdl=DVDs|DVDs+with+Scracthes&chdlp=b&chl=44|5&chma=40,60,0,40&chtt=DVD+Report&cht=p3&chco=751010|FFCC33 In the page load event i have the following:
[Code]....
[Code]....
I place a break point on the line where i set the src and as i step thru everything is correct and the src is being populate with the correct link, but when i step past that line, then i get the null reference.Now why is it that i can paste that link to the browser and it works.. and if i hardcode that link in the image src on my aspx page and comment out the code behind it works there also..
View 17 Replies
Apr 8, 2010
This is probably something silly I'm missing but I'm definitely lost. I'm using .NET 4 RC and VS 2010. This is also my first attempt to use UpdateModel in .NET 4, but every time I call it, I get an exception saying Value cannont be null or empty. I've got a simple ViewModel called LogOnModel:
[Code]....
My view uses the new strongly typed helpers in MVC2 to generate a textbox for username and one for the password. When I look at FormCollection in my controller method, I see values for both coming through.
And last but not least, here's are post controller methods:
[Code]....
why UpdateModel would be throwing this exception?
View 4 Replies
Aug 6, 2010
How can I take an exception (if occured) and save it or display it and pass the error message to another page?
View 8 Replies
Jun 30, 2010
I am using httpcontext.Current in one my action method and i created the ms test method for testing this action and also i created the Mock object for httpcontect,but when i am trying to run the MS test script i am getting null reference exception from the line which i am using httpcontext.current in the action method.
View 1 Replies
Jul 10, 2010
I have created a masterpage where I require user login. The content pages are only displayed if the user is authenticated.
<LoggedInTemplate>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</LoggedInTemplate>
On my content page I have
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:DropDownList ID="dropdown1" runat="server"></asp:DropDownList>
</asp:Content>
When run, I can successfully authenticate and then when I attempt to view this particular content page I get an error on the page load where I'm trying to populate the dropdownlist. The error I get is a Null Reference exception. I don't fully understand the page lifecycle of an asp.net page, but I also don't understand why the page compiles successfully and its only when run that I get this exception. It seems that the control is not created when the page_load command is called. How can I change the contents of a dropdownlist on page load of a content page that requires authentication?
View 6 Replies
Sep 2, 2010
I have an Asp.net web service that I created using Visual Studio 2005. I can acess the web service in my test environment, call methods and return data as expected. If this web service is published to the outside world (Outside of the company firewall), it will return a null why this might be happening? The same code is being used,against the same database. The only difference is that the published website is giving back the null reference exception. If I type in the URL for the web service "https://secure.theSiteGeist.com/wsIndigo.asmx" a list of methods for the web service is displayed in my browser. Yet if I try and call any methods on the web service I get back the null reference exception. Note that the URL I posted above is not the real name of my web service, but is just used for reference sake.
View 3 Replies
Dec 10, 2010
I am getting the Null reference exception in
[Code]....
also when I used the Quickwatch, I get this error message.
getElementById The name 'getElementById' does not exist in the current context
I am also using Master Pages.
View 5 Replies
Jan 10, 2011
How can I use ChatRoom With Master page. If Run the Code then Follwing Error generatException Details: System.ArgumentNullException: Value cannot be null.Parameter name: StringSource Error:
[Code]....
Source File: ChatEngine.cs
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] == null)
[code]...
View 1 Replies
Nov 24, 2010
I have created one itemtemplate to display one button in subgrid(grid in grid) in .ascx page:
<asp:datagrid id="grid1" runat="server>
<columns>
<asp:TemplateColumn HeaderText="Close Manually" ItemStyle-HorizontalAlign="left">
[code]...
View 2 Replies
Nov 13, 2010
i get a null reference exception for this code.//was trying to retrieve cookie, who's name is attached as query string.
string cookieName = Request.QueryString["CookieName"].ToString();
View 1 Replies
Jun 2, 2010
I have code that's working beautifully on my development machine,but when deployed to the server is throwing null reference exception.So,I can't step through the code,but I've pinned down the culprit.But now I am puzzled.Here's the code.The question is below.
Dim certs = From p In persons _
Select New Certificate( _
p.Value, _
New CertificateData.Seminar(thisEvent.Seminar.Name, _
[code]...
In the code above persons is a dictionary of custom class,and certs is of IEnumerable type.Now here's the quandary.The first line that sets the label returns False,so certs is not null.But the second line throws an null reference exception.
View 1 Replies
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
Dec 15, 2010
let me see if I can explain this clearly. I have a gridview control
and I am trying to use the Edit function. In my gridview, there are numerous rows. I pick one to change and click Edit. I then see the boss name in my gridview and click "Change". When I click Change, I'm expecting two fields to appear, one is a label, the other is a DropDownList. I get this error when I click:
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=App_Web_lzmklgbg
StackTrace:
at Training_TRManageOrg.LinkButton1_Click(Object sender, EventArgs e) in d:projectsediting.aspx.cs:line 108
at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Gridview HTML:
<asp:TemplateField HeaderText="Director">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("director") %>'></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Change</asp:LinkButton>
<asp:Label ID="Label4" runat="server" Text="Director" Visible="False"></asp:Label>
-
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="trDirector"
DataTextField="name" DataValueField="id" onselectedindexchanged="DropDownList2_SelectedIndexChanged"
Visible="False"></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("director") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Code Behind:
protected void LinkButton1_Click(object sender, EventArgs e)
{
DropDownList DropDownList1 = ((DropDownList)FindControl("DropDownList1"));
DropDownList1.Visible = true; // this line is where the exception occurs
Label3.Visible = true;
}
I figure I must be overlooking something so I'm asking what am I missing?
View 4 Replies
Oct 19, 2010
I am stuck into a problem, i have a user control ProductListing.ascx that contains ListView binded to an object datasource, SelectMethod and SelectCountmethod are provided as well. Everything works fine but the problem started when i add another user control declarativlly Filter.ascx in the productListing.ascx. I want to assign value to a public property MaxPrice in Filter.ascx. I am trying to set this property in the SelectMethod of ObjectDataSource. Usercontrol "Filter.ascx" throws null reference exception when i try to set its MaxPrice Property.
I tried to acced the usercontrol in Databind method of ListView , it is accessible here but viewstate is empty at this point, i saved the value in viewstate in SelectMethod of objectDatasource but i cant access viewstate in ListView Databind. Its empty. Its a simple code and no rewriting to viewstate elsewhere.
Important: My Codebehind files are in a seperate project and .ascx files in seperate project
View 1 Replies
Aug 20, 2010
I developed a page in VWD 2008 and it works perfectly locally, but when I deployed it on the server every Page.FindControl() call is causing the NullReference Exception "Object reference not set to an instance of an object. " Can anyone help me out? Code is below
[Code]....
View 1 Replies
Mar 8, 2010
I' m using a web custom control to upload images and mark them as primary. all the flow is working fine but it fails to mark images as primary in a diffrent category(there are four categories in which we can load a image-,catalog,primary,misc).It works in - category but not in others when I debug it is failing at a condition in grey . If it is not an element of the Datalist item it would not even enter the loop. I' m lost and unable to find the reason.
View 2 Replies