C# - GetRequestStream Throws Timeout Exception Randomly

Feb 12, 2010

After googling for couple of days, I really cannot solve described issue. Hope here will find a solution

I'm using attached code when calling WCF service on the same server. I get Timeout error randomly in call WebReq.GetRequestStream()

When I'm check netstat I see that connection remains open, so probably is there a problem, but I don't know how to solve it

//request inicialization
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(url);
WebReq.Method = "POST";
WebReq.ContentType = "application/json; charset=utf-8";
WebReq.ContentLength = buffer.Length;
WebReq.Proxy = null;
WebReq.KeepAlive = false; //also tried with true
WebReq.AllowWriteStreamBuffering = false; //also tried with true
//this produces an error
using (Stream PostData = WebReq.GetRequestStream())
{
PostData.Write(buffer, 0, buffer.Length);
PostData.Close();
}
//open and read response
HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
Stream Answer = WebResp.GetResponseStream();
StreamReader _Answer = new StreamReader(Answer);
WebResp.Close();
//return string
return _Answer.ReadToEnd();

Timeout is thrown mostly after some 10 seconds of idle time, but also after five or so requests in the row. Really cannot find a pattern.

What could be wrong with this code? Is there any other (better) way for calling WCF service?

View 4 Replies


Similar Messages:

Mobiles :: Exception While Calling HttpWebRequest.GetRequestStream()

Mar 17, 2010

From my windows mobile application, i want to connect to the server which resides on my local machine. I want to use HTTPS.

SSL certificates have been implemented and they dont cause any problems.

However, i get an exception at the code line

Stream requestStream = webrequest.GetRequestStream(); ----> webrequest is an object of HttpWebRequest class

The exception message is "Could not establish connection to network." InnerException is null.

View 2 Replies

Console Application Calling Datalayer Throws An Exception "The Type Initializer For Threw An Exception."

Aug 17, 2010

I have simple 3 tier web application and have mostly CRUDE functionalities. Recently I required to add new console application to the existing solution in which I call data layer methods for retrieving data from DB but I get an exception "The type initializer for threw an exception."When I debugged I found that the exception is thrown at datalayer on first line of class where I get connectionstring from

web.config, the code is public static readonly string CONNECT_STRING =

ConfigurationManager.ConnectionStrings["DbConnectString"].ConnectionString;

Now if I hardcode the connection string value like public static readonly string CONNECT_STRING = "Data Source=XYZ;uid=sa;password=XXX;initial catalog=ABC;"

it works fine.I don't understand what is the issue here as web application works fine with this datalayer.

View 2 Replies

ADO.NET :: Web Application Throws An Exception Now And Then?

Jan 17, 2011

every now and then my server throws an exceeption. When it first starts to throw an exception the server wont work until I reinstall my web app (copy and Paste). I think this forces a restart of IIS and somethiong gets cleared bercause the app is working again for some hours, sometime less. Now I have created a scheduled task recopying all the web site files every 15 minutes. This restarts the server and the users are able to use the site. Problem is that now the server either start throwing exceptions, or the user is kicked because the server restarts. So you see, this is absolutly not a good solution.I have looked in the Event Viewer on the sever. Her is some examples of the exceptions:

[Code]....

An other exception:

[Code]....

As you can see, the common part of all the exceptions is the Exception message: Unable to cast object of type 'System.Int32' to type 'System.String'. Her is the code of one of the places throwing an exxception:

[Code]....

View 3 Replies

C# - Creating XMLSerializer In .net Throws Exception

Jul 22, 2010

We have an old asp application that instantiates a .NET com visible class. In this class, we do some serialization to store our object in the session.

When I call the following line of code in my test class, it works fine.

var cereal = new XmlSerializer(couponApplicator.GetType());

However, when it gets called in the website and I am debugging, it throws the following error:

{"Cannot execute a program. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /noconfig /fullpaths @"C:\WINDOWS\TEMP\rwot-yx9.cmdline"."} System.SystemException {System.Runtime.InteropServices.ExternalException}

I thought maybe it was permissions related so I tried giving 'EVERYONE' full control to the windows/microsoft.net folder as well as the windows/temp folder. For reference, I am running this on a Windows XP machine.

View 2 Replies

Using A RenderAction Method Throws An Exception

Dec 29, 2010

i have this (simple) code

<% Html.RenderAction("Version", "Generic"); %>

in my masterpage of my asp.net mvc 2 app. This method returns the version of the application.

i also have this code in my controller:

class GenericController : BaseController
{
[ChildActionOnly]
public string Version()
{
try
{
string assemblyFile = Assembly.GetCallingAssembly().FullName;
FileInfo fi = new FileInfo(assemblyFile);
string version = fi.LastWriteTime.Year.ToString( ) + fi.LastWriteTime.Month.ToString() + fi.LastWriteTime.Day.ToString();
return version;
}
catch (Exception e)
{
return "1.0";
}
}
}

Now i get this error:
Execution of the child request failed. Please examine the InnerException for more information.

and the innerexcpetion is:
{"The controller for path '/Account/LogOn' was not found or does not implement IController."}

What i was thinking is that maybe the code can't execute because the user is not logged on yet, and tries to redirect to the logon method etc.

So the first thing i was thinking is to grant access in the web.config (like i do with the directory that has the css and images in it, it should also be accessable when you're not logged on:

<location path="Content">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

but what is the path for this (version) method ?

(or maybe there is another reason for the excpetion.

View 1 Replies

MVC :: Custom Authorization Attribute Throws Security Exception

Mar 4, 2010

I have a custom authorization attribute, that basically check if the current user's role is equals to the current area name, and if not, redirect them to the signup view in that requested area. (dummy role provider at this this stage, therefor check it against the user's name at the moment)

It runs fine (IIS) but when I debug it I can see a Security Exception are being thrown by the code

The code:

[Code]....

View 2 Replies

Setting DefaultButton To Button.UniqueID Throws Exception?

Jan 31, 2011

I have several text boxes in an asp:Panel. When the user hits Enter from any of those boxes, I want the form to submit as if they've clicked btnAddTag. (When the cursor is not in those boxes, I have a different default submit button.)

The aspx:

<asp:Panel id="thePanel" runat="server">
<asp:Button ID="btnAddTag" Text="Add Tag" runat="server" />
</asp:Panel>

The vb:

tagPanel.DefaultButton = btnAddTag.UniqueID

The exception:

The DefaultButton of 'tagPanel' must be the ID of a control of type IButtonControl.

The value of btnAddTag.UniqueID is ctl00$phMain$btnAddTag (there's a master page, this section is called phMain).

I've also tried CType(tagPanel.FindControl("btnAddTag"), Button).UniqueID.

View 3 Replies

ADO.NET :: What Is The Purpose Of Adding A Try Catch Condition That Simply Throws The Exception?

Sep 30, 2010

What is the purpose of adding a try catch condition that simply throws the Exception?

Sample Code (Note: The db object is proprietary code that simply uses ADO.Net):

[Code]....

View 6 Replies

Security :: Membership.DeleteUser Throws Exception When Website Is Published

Mar 29, 2010

I am using Membership.DeleteUser("username",true) method to delete the user from DataBase. This works fine in my local machine. When i publish the same code, i am not able to delete the user..... it throws an javascript error saying..... "Login failed for user NT AUTHORITY/NETWORK SERVICE"

View 5 Replies

ADO.NET :: Typed Dataset Throws Null Value Exception For Datetime Field?

Nov 12, 2010

I have a date field in a typed dataset that created from database.

I get an NULL Value exception when I try to enter some null value. I am not able to set the Nullvalue property of the DateTime field in XSD to other value other than Throw Exception.

View 1 Replies

AJAX :: DropDownExtender Inside List View Throws A JavaScript Exception

Apr 23, 2010

The following code listed on the bottom is a dropdown extender contained with a listview insert template. The code works fine however int VS 2008 Debug mode, its throwing the exception:Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.If I click ignore or continue, the taret label is properly populated with the appropriate value. Has anybody encountered this and is

<td>
<asp:Label ID="lblTest" style="height:25px;border: solid 1px black" runat="server" Text='<%#Bind("TestCode") %>' Width="90%"></asp:Label>
<asp:DropDownExtender ID="ddExtTestCode" runat="server" TargetControlID="lblTest" DropDownControlID="pnlTestCode"></asp:DropDownExtender>
<asp:Panel ID="pnlTestCode" runat="server" style="display : none; visibility: hidden;">
<asp:LinkButton runat="server" ID="Option1" Text="12345-New York" CommandArgument="12345" OnClick="OnTestCodeSelect"></asp:LinkButton>
<asp:LinkButton runat="server" ID="Option2" Text="45678-New Jersey" CommandArgument="45678" OnClick="OnTestCodeSelect"></asp:LinkButton>
</asp:Panel>
</td>

View 1 Replies

State Management :: Cast From Cache To Generic List Throws An Exception

Mar 17, 2011

In Asp.net application. i cache a Linq to Xml result to a Cache object. when i cast the cache object back to generic list. i get the following exception.

[A]System.Collections.Generic.List`1[CarRentalAddress] cannot be cast to [B]System.Collections.Generic.List`1[CarRentalAddress]. Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'. Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'.

My code looks like this.

if (!Page.IsPostBack) { if (Cache["xml"] == null) { DataSet ds = new DataSet(); ds.ReadXml(HttpContext.Current.Server.MapPath("~/CarRentalAddress.xml")); var grid = (from d in ds.Tables[0].AsEnumerable() orderby d.Field<string>("City") where d.Field<string>("Enabled") == "1" select new CarRentalAddress { City = d.Field<string>("City"), HotelName = d.Field<string>("HotelName"), Address = d.Field<string>("Address"), EmailID1 = d.Field<string>("EmailID1"), EmailID2 = d.Field<string>("EmailID2") }).ToList(); Cache["xml"] = grid; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } else { //Exception is thrown by this line var grid = (List<CarRentalAddress>)Cache["xml"]; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } }

View 4 Replies

Localization :: DateTime Conversion / Date Doesnot Work And Throws Exception?

Jul 30, 2010

I am working on application which is deployed in UK environment. But the machine which I am using has US as dateculture.

I always face issues while running application on my machine as some of the functionality which involves date doesnot work and throws exception.

I tried to google on the datetime conversion issue but it did not help.

Can any one please guide me about the changes to be done so that the application works fine in both US and UK environments?

View 2 Replies

Visual Studio :: Visualizer For LINQ To SQL Throws Exception When Encountering A Timestamp - Rowversion In The Data

Jan 10, 2011

This problem is trivial to duplicate. Do any query on a table which contains a timestamp / rowversion column. Set a breakpoint and examine the resulting query in the Linq to SQL visualizer. Click on Execute which displays the results in a DataGridView. For each row you get "System Argument Exception: Parameter is not valid" when it tries to display the timestamp / rowversion in the grid. What is most annoying is that there is no way to get out of the visualizer without going to Task Manager and killing the Visual Studio process, devenv.exe.

This is definitely a bug. How can you presume to be able to display a database query when you can't display an essential datatype like timestamp / rowversion? Is there any way around this ? I would like to add that in general the CLR is woefully inadequate in the way it handles timestamp / rowversion fields. It would be nice if they could be defined, copied, compared, displayed and serialized in some standardized automatic way.

View 3 Replies

AJAX :: AjaxControlToolkit.ToolKitScriptManager.OnInit() Throws Thread Abort Exception For Every Aspx Page

Nov 3, 2010

AjaxControlToolkit.ToolKitScriptManager.OnInit() throws thread abort exception for every aspx page. I have an asp.net 2.0 Ajax application, where I have set the following properties of ToolScriptManager on my pages.

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="true"
EnableScriptLocalization="true" CombineScripts="true" EnablePageMethods="true">
<Scripts>

I have this configuration on all the aspx pages in my application. When I checked the .NET CLR exception Performance counter I figured out a large number of exceptions, mainly one exception per page load is occuring. On running windbg I was noticed that

AjaxControlToolkit.ToolKitScriptManager.OnInit() has the following code block which is getting executed. The OutputCombinedScriptFile() returns true. But since I am setting my controls on DesignTime still designmode is set to false for toolkitscriptmanager.

if (!DesignMode && (null != Context) && OutputCombinedScriptFile(Context))
{
// This was a combined script request that was satisfied; end all processing now
Page.Response.End();
}

I am not sure if this is a reported bug or even a bug with ajax, but this is causing havoc in my load test results as I have around 3 hundred thousand HTTP requests to be handled per day out of which 80% are aspx page requests resulting in a large number of threadafbortexceptions, thus affecting the performance.

View 3 Replies

State Management :: How To Catch Session Timeout Exception

Jun 25, 2010

I need to create a small web application. The first thing I need to do is to develop the login, logout and user session management functionality. I wanted to use a masterpage and a usercontrol for this purpose. When a user open the page and IS LOGGED IN, the usercontrol should something like this:
"Hello Username! <a>Logout</a>"
And if he is NOT LOGGED IN, the Usercontrol should show something like this
"Login | Logout"

When he clicks on the Login Button the Login-page should be opened. How can I build a Usercontrol which does the above thing. (I have never build a usercontrol and used it in a masterpage before!) The second problem is a little bit komplexer: What happens if the user idles some times and after that time (for example 30minutes) comes back to his pc and wants to execute an action in the web application. Normally he should get an session timeout asp.net exception. I don't want that the user sees this asp.net errorpage, I want to redirect him to the Login Page and he should relogin and gets an error message shown something like "You were timed out. Please login again".

View 5 Replies

Cannot Load An Entity In NHibernate Then Timeout Exception When Table Is Existing

Oct 11, 2010

I got this error while inserting/updating a number of records

could not load an entity:
[Star.CNPL_BusinessObjects.Entities.CNPL.CNPL_AgencyProduct#48][SQL: SELECT cnpl_agenc0_.Id as Id48_0_, cnpl_agenc0_.AgencyID as AgencyID48_0_, cnpl_agenc0_.ProductID as ProductID48_0_, cnpl_agenc0_.CreatedDate as CreatedD4_48_0_, cnpl_agenc0_.CreatedBy as CreatedBy48_0_, cnpl_agenc0_.UpdatedDate as UpdatedD6_48_0_, cnpl_agenc0_.UpdatedBy as UpdatedBy48_0_ FROM CNPL_AgencyProduct cnpl_agenc0_ WHERE cnpl_agenc0_.Id=?]"
[code]...

View 2 Replies

State Management :: Form Timeout Vs. Session Timeout Vs. Connectionstrings Timeout?

Jan 27, 2011

We have the timeout value set to 120 in our <form> tag within the web.config. We do not have a session timeout set.. and we have various connection strings.

We are having a problem where a session variable will disappear (become NULL) .. but, the form evidently remains 'open'.. or no re-login is required..... so, my question(s):

1. what is the relationship between form timeout and session timeout

2. how do I set session timeout

View 1 Replies

"d+{1,4}(?:[.,]d{1,4})?" In RegularExpressionValidator Throws Exception: "Nested Quantifier {"

Apr 29, 2010

I have asp:RegularExpressionValidator with ValidationExpression="d+{1,4}(?:[.,]d{1,4})?" but it doesn't' work, parser throws ArgumentException:

parsing "d+{1,4}(?:[.,]d{1,4})?" -
Nested quantifier {.

Where is my mistake? I want to allow strings like xxxx,xxxx - from 1 to 4 digits and decimal digits are not required, e.g.: 1000, 99,99, 0,2498, etc.

View 3 Replies

VS 2008 Timeout Exception - Webservice Running Query On Sql Server 2008?

Jun 24, 2010

I have a web service that runs a query (from C#) to get a dataset from sql server. I get the following time out error. Googling on this error says, you can set the timeout on command object. But I am not using command object to set the timeout. This is the code I am using to get the dataset.

code:

[code]....

View 8 Replies

DataSource Controls :: SQL Statement Timeout / System.Data.SqlClient.SqlException: Timeout Expired?

Jan 20, 2010

Hopefully I am posting this in the correct forum.

I am having a problem with my ASP.Net Web application. The application is developed using vb.net and is linked to a SQL Server database. Let me explain how the application works and the problem I am experiencing. The system is an online web app which allows registered users to create a CV online. One of the pages within the app gives users the chance to add a cover note to their CV. The page that allows them to do this consists of only a textarea control and a button control. The textarea allows users to input up to 4,000 characters.

Once the user clicks the 'Save' button to save their cover note info, the following code then executes.This code checks to see if the CV already has cover note info, if it does, then the application runs an update statement, otherwise, it runs an insert statement.The table within the database which records the cover note information is called tbl_covernote and has three columns, covernote_id (int and autoincrement), cv_id(int), covernote_text (nvarchar(max)).

The error which occurs sometimes is as follows:

Dim dr As SqlDataReader
Dim param(0) As SqlParameter
Finally [code]...

View 11 Replies

AJAX Timeout Although Request Is Completing Long Before Timeout Duration

Feb 15, 2010

I have an ASP.Net application that makes an AJAX request to retrieve at report. The report can run for a long time so I set the asyncpostbacktimeout in <asp:ScriptManager /> to 600. However, when I try to run the report, if it runs for longer than 90 seconds it fails to come back. I can see in the IIS logs that the POST request succeeded with a 200 status and I can see the time taken is much less than 600.

The web page dutifully waits for the entire 600 seconds before returning with a timeout error:

Error:

Sys.WebForms.PageRequestManagerTimeoutException:

The server request timed out.

Is there any setting I should be checking in IIS? Connection timeout is 900 seconds.

View 1 Replies

Differences In Forms Auth Timeout And Session Timeout?

Feb 1, 2010

The session state timeout is set using this web.config element

<sessionState mode="InProc" cookieless="false" timeout="120" />
The forms auth is configured using this web.config element
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx"
protection="All"
timeout="30"
name=".ASPXAUTH"
path="/"
requireSSL="false"
slidingExpiration="true"
defaultUrl="default.aspx"
cookieless="UseDeviceProfile"
enableCrossAppRedirects="false" />
</authentication>
</system.web>

What is the difference between the timeouts specified in each of these elements? If both are different, how would it work?

View 2 Replies

Javascript - Sync JS Timeout And Session Timeout?

Jul 29, 2010

I have a page of each every click has ajax call to my server (hence, the ASP extends the session)

I have ASP.NET session set to Xmin. I want when X+1 min expires, I have expiration page. what I did was to set the JS timer to validate every x+1min to see if the session expired (the problem is that the JS and the ASP session timeouts are not synced)

View 2 Replies







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