C# - Prevent Or Handle Time Out With XmlReader.Create(uri)?

Aug 23, 2010

Sometimes I am getting a time out exception when reading an XML via a URL. Is there something I can do to prevent this, or is this a problem with the remote server? Below is my simple code:

XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create(this.RssUrl));

I do not know how to pass that setting into the code above (or if that is even the correct solution): [URL]

Exception Details: System.Net.WebException: The operation has timed out

Stack Trace:

[WebException: The operation has timed out]
System.Net.HttpWebRequest.GetResponse() +5375213
System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials) +69
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +3929371
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54
System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext) +144
System.Xml.XmlReader.Create(String inputUri) +8

View 1 Replies


Similar Messages:

C# - Get An XML Attribute With XmlReader.Create?

Aug 21, 2010

I am using XmlReader.Create to retrieve data from an RSS xml file. Then I am putting this data into a DataSet and binding it to a ListView:

XmlReader xmlReader = XmlReader.Create(this.RssUrl);
XmlDataDocument xdoc = new XmlDataDocument();
xdoc.DataSet.ReadXml(xmlReader, XmlReadMode.InferSchema);

The problem is that one of the fields I am trying to get is in an attribute. How do I get the "url" attribute from "media:thumbnail" below?

<item>
<title>Some Title</title>
<description>Content goes here...</description>
<link>http://www.mydomain.com?id=439</link>
<guid>453252362</guid>
<pubDate>Sat, 21 Aug 2010 11:00:00 GMT</pubDate>
<media:thumbnail url="http://www.mydomain.com/catalog/1111tn.jpg" />
<media:content url="http://www.mydomain.com/catalog/1111.jpg" />
</item>

I am bind it like this, but the media:thumbnail is null obviously because I need to get the attribute some how:

void singleItem_DataBinding(object sender, System.EventArgs e)
{
Label singleItem = (Label)sender;
singleItem.Text = String.Format(@"
<div class=""rlvI content"">
<div class=""image"">
<a href=""{0}""><img src=""{1}"" alt=""{2}""></a>
</div>
<p>
span class=""title"">{2}</span><br />
{3}
</p>
</div>",
((singleItem.NamingContainer as RadListViewDataItem).DataItem as DataRowView)["link"],
((singleItem.NamingContainer as RadListViewDataItem).DataItem as DataRowView)["media:thumbnail"],
((singleItem.NamingContainer as RadListViewDataItem).DataItem as DataRowView)["title"],
((singleItem.NamingContainer as RadListViewDataItem).DataItem as DataRowView)["description"]);
}

View 1 Replies

C# - How To Prevent Or Handle Tampering With Form Data Of Disabled Fields Before Submission

Apr 6, 2010

If a disabled drop-down list is dynamically rendered to the page, it is still possible to use Firebug, or another tool, to tamper with the submitted value, and to remove the "disabled" HTML attribute.
This code:

[code]....

The problem occurs when I use Firebug to remove the "disabled" attribute, and to change the selected option.On submission of the form, and re-creation of the field, the newly generated control has the correct value by the end of OnLoad, but by OnPreRender, it has assumed the identity of the submitted control and has been given the submitted form value.

.NET seems to have no way of detecting the fact that the field was originally created in a disabled state and that the submitted value was faked. This is understandable, as there could be legitimate, client-side functionality that would allow the disabled attribute to be removed.

Is there some way, other than a brute force approach, of detecting that this field's value should not have been changed?

I see the brute force approach as being something crap, like saving the correct value somewhere while still in OnLoad, and restoring the value in the OnPreRender. As some fields have dependencies on others, that would be unacceptable to me.

View 4 Replies

Caching - What Techniques Should Be Used To Handle Objects In Asp.net Cache To Prevent Problems From Multiple Worker Threads Access

Sep 8, 2010

since asp.net contains multiple threads that are executing at the same time.so if 2 threads access an object (simple or complex) that i got from the the asp.net httpcontext Cache.can't this lead to state problems on that object if these 2 theads tried to modify/read it at the same time?so what kind of precautions should i implement?for example i am thinking maybe locking the object while working with it? (wont this cause performance problems?)or maybe when i retrieve some object from the cache i should create a copy from it?
or maybe i dont need to worry about this issue at all?

View 2 Replies

How To Handle Time Input In C#

Jun 25, 2010

How am I going to handle time input because I am having a problem especially if the user inputs greater than 24:00:00.

View 2 Replies

Handle Time Difference In MVC?

Jan 23, 2010

I've published a web application to a server in the USA. The app is actually for swedes (people in Sweden) and I am looking for the best way to hadle the time difference.

There's a +7 hour difference.

Should I store the DateTime.Now in DB as it is, or should I use DateDiff to change the time before creating each record?

What's the best practice here? What to store in the database? Should the date only be differed when presenting it?

View 1 Replies

C# - Handle Different Time Zones In A Website?

Aug 16, 2010

I got this answer from Kjensen and read the answers, but this is a different webapp

I'm running scheduled events that process incoming orders, set Picking material, manage Track & Trace numbers, etc ... and I do this at a specific time of the day (set in Administration Panel)

My server is in UK (DiscountAsp.net) but I'm 2 hours ahead.

What I really wanted is, every time I call DateTime.Now that would be automatically changed to my time instead of Local Server Time. This should handle Daylight savings as well.

I thought about making a Extension to simply call DateTime.MyLocalTime and there use TimeInfo to add / subtract the correct hours.

In good old days I did this in Global.asa (ASP) ... I just wanted to know if there is a better way to handle this.

View 1 Replies

DataSource Controls :: Invalid Command Sent To ExecuteXmlReader Error While Executing Xmlreader?

Mar 23, 2010

when i am executing xmlreader in enterprise library 4.1, iam getting an error like below

error: Invalid command sent to ExecuteXmlReader. The command must return an Xml result.

my code:

SqlDatabase

db = (
cmd = db.GetSqlStringCommand(
xmlReader = db.ExecuteXmlReader(cmd);
db = null;DbCommand cmd =
null;XmlReader xmlReader =
null;SqlDatabase)DatabaseFactory.CreateDatabase();"select
* from emp");DataSet ds = db.ExecuteDataSet(cmd);

View 1 Replies

C# - Prevent Duplicate Record On Run Time?

Jan 18, 2011

This code cause double record... i checked my insert code for all tables and it works fine...

and this is insert code:

StoreDO store = new StoreDO();
List<BrandDO> brandList = new BrandBL().SelectBrands();
StoreBL storeBL = new StoreBL();
store.StoreName = txtStoreName.Text;

[Code]....

View 1 Replies

Forms Data Controls :: C# - Create A 'Time" Column Which Shows The Elapsed Time In HH:MM Format?

Mar 18, 2010

I have 2 fields being displayed in a Gridview, StartTime, EndTime. I want to create a 'Time" column which shows the elapsed time in HH:MM format. (StartTime - EndTime) This was all generated with VS2008, table is pulled from an SQL Query.

View 1 Replies

Web Forms :: Trying To Create An App Which Shows Current Time In 6 Time Zones

Mar 15, 2010

I am trying to create an app which shows current time in 6 time zones (Sydney, S'pore, india, london, EST and CST).

I am having troubles handling DST, because DST starts and ends on different dates in different countries.

More over I want to make it configurable (add/remove cities from the list).

Currently I have added the cities in .config with their timezone differences (with respect to GMT).

[code]....

View 3 Replies

SQL Server :: Write A Stored Proc To Prevent Multiple Users In Uploading The Reports At A Time?

Aug 11, 2010

I wanted to know how to prevent more than one user from uploading the report at a time .

This is a Windos based app written in c# . When User A clicks Upload option on one server from the menu to upload the files and at the same time when User B clicks Upload option on different server , User B should be alerted a message saying "User A's uploading is in progress,pls wait" . How to achieve this, with the code..I am thinking this logic should be kept in a stored proc, How do I write that proc?

View 6 Replies

Web Forms :: Create One Subroutine To Handle All Deletes For Page?

Mar 5, 2011

I am trying to create one subroutine that can handle all deletes for a web app. I have one delete popup panel in my master page, and I call it each time from my content pages. When an instance of delete is called from a content page, I store the name of a delete subroutine specific to the delete instance in a session variable and popup the delete panel in the master page. If a user types YES into a delete textbox in delete popup panel, a confirmDelete Subroutine in codebehind of the Masterpage is called. When the confirmDelete subroutine in the Masterpage is callled, I want to call a subroutine in the content page that has the name stored in the session variable. What is the simplest way to do that?

View 1 Replies

C# - Create Method To Handle Multiple Types Of Controls

Mar 30, 2010

I am trying to create a method that accepts multiple types of controls - in this case Labels and Panels. The conversion does not work because IConvertible doesn't convert these Types.

public void LocationsLink<C>(C control)
{
if (control != null)
{
WebControl ctl = (WebControl)Convert.ChangeType(control, typeof(WebControl));
Literal txt = new Literal();
HyperLink lnk = new HyperLink();
txt.Text = "If you prefer a map to the nearest facility please ";
lnk.Text = "click here";
lnk.NavigateUrl = "/content/Locations.aspx";
ctl.Controls.Add(txt);
ctl.Controls.Add(lnk);
}
}

View 1 Replies

Httpresponse - How To Handle Errors When Using C# To Create A Zipfile For Download

Oct 29, 2010

I'm working on a functionality in my asp.net web site that enables the user to download some files as a zip file. I'm using the DotNetZip library to generate the zip file.

My code looks like this:

protected void OkbtnZipExport_OnClickEvent(object sender, EventArgs e)
{
var selectedDocumentIds = GetSelectedDocIds();
string archiveName = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
AddResponseDataForZipFile(Response, archiveName);
try
{
string errorMessage = Utils.ExportToZip(selectedDocumentIds, arkivdelSearchControl.GetbraArkivConnection(), Response.OutputStream);
if (!string.IsNullOrEmpty(errorMessage)).......

Now, if anything goes wrong, say the Utils.ExportToZip method fails, I want to present an error message to the user and not the download dialog. Do I have to remove some data from the Response object in order to cancel the download operation?

View 2 Replies

DataSource Controls :: Create And Handle Wide Tables Programmatically?

Apr 15, 2010

I have a set of keywords (about 1000 keywords), and I want to build a wide table, up to 1000 columns:

+each column corresponding to a keyword

+each row will represent an article document, which each cell will be the frequency of the keyword in the document

How to do that in a programmatically way? (e.g., using Linq and C#)

View 4 Replies

Want To Create A Webpage Which Can Handle User Events Like Page Navigation And Page Close

Sep 13, 2010

I would like to create a webpage which can handle user events like page navigation and page close. And also I would like to handle the event on server-side coding.

View 1 Replies

C# - Create Control In Run Time?

Jul 21, 2010

I had task in web solution as button when I click on the button it create data list with some controls on data list and when I click second it create second data list and so on I want to know how can I do this?

View 1 Replies

MVC :: Create The Models Classes All The Time ?

Jan 7, 2011

Do I need to create the Models classes all the time ?

such as

[Code]....

I would like to use the classes straightly ,that is generated by Linq to sql?

View 1 Replies

Web Forms :: Create Xml File At Run Time

Feb 9, 2011

In our application, we have a menu control that is bound by an xml file. This xml file will be created at run time based on the role/permission configuration. Of course, It is ideal to have this xml file created and lives in the memory. When a user log off or close the browser, its xml file is killed.

menuControl.Itemsource = "newlycreated.xml";

is the syntax to bind the xml file to menu control. I don't have an idea how to do it just yet.

View 2 Replies

Web Forms :: How To Create Panel With Controls At Run Time

Dec 2, 2010

I am creating an application where up to 50 people could register for an event. On this part of the application, I have a dropdown menu that contains values from 1 to 50 and autopostbacks to create panels with controls inside equal to the number selected in the dropdown menu. The code for that is below:

[Code]....

The code above works pretty well for the most part (I'll explain the small glitch I found more below). But now on a button to submit the registration, I want to grab that data and insert it into a SQL database. However, when the button is clicked those fields disappear because of the postback to the server. I also noticed that if a new number is selected in the dropdown menu, all the fields clear out as well. I know I would be pretty angry if I entered 40 some names and and needed to re-enter them all again just because I chose the wrong number initially on the page. So I know the code above needs a small tweak.

This is my first time working with control generation at run time, so I am a bit stumped on how to properly set this up.

[Code]....

View 3 Replies

VS 2008 - How To Create Multiple Control At Run Time

Oct 24, 2010

i need a form in such a manner that if uesr select 1 it create 1 small form/panel on web page if select 2 it will create 2 small form/panel on web page etc etc

[code]....

then i need to store record thenin database when user fill run time form/panel etc etc

View 13 Replies

Create A Dynamic Webpage Each Time As Requirement?

Jun 30, 2010

I have some suitation where i want to store aspx controls in SQL Server database and retrive on aspx.cs page according to database i want to design my aspx page and also event handler to them.

Controls may be vary time to time according to suitation and aspx page changes all time according to suitaion.

For Example :

I want to display a information about Computer and Technolgy the aspx page will be display only Computer related topics like 1. Computer Name 2. Price 3. Discount

but in other case I want to display information about City Information then Display 1. City Name 2. Distance from nearest city. 3. City Map 4. About City 5. Query or book a car. extra - extra.

View 1 Replies

How To Create RDLC Form Dynamically In Run Time

Feb 9, 2011

how to create RDLC form dynamically in run time and how to save it in asp.net c# ?

View 1 Replies

Like To Create A Progress Bar With Real Time Updates On The Different Method?

Sep 30, 2010

I would like to create a progress bar with real time updates on the different method calls that happen on a button click in asp.net 1.1. I have seen some examples but nothing that provides updates on the progress bar while the server side operation executes.

View 1 Replies







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