Posts

Showing posts from January, 2009

Circular reference error in Object Serialization in Asp.Net using C#

Category object is a typical object that requires parent/children relationship. What's more, it is a common practice that the child object will require a parent object reference. When we use object serialization, it is very important that we set the parent object as [XmlIgnore]. Otherwise, the serialization will raise an exception as following: Circular reference was detected while serializing an object Categories. The following is the code sample. /// /// Summary description for Categories /// public class Categories { [XmlIgnore] public Categories m_parentCategory; public Guid m_CategoryID; public string m_CategoryName = ""; public short m_iLevel = 0; public static Categories rootCategory = null; public List m_oSubCategories = new List (); public void Save(string fileName) { FileStream fileStreamCreate = new FileStream(fileName, FileMode.Create); XmlSerializer serializerCategory = new XmlSerializer(typeof(Catego...

Shared ASP.NET project on Popfly

I have just created a demo project to navigate file structure in hosting environment, create/delete folder, create/delete xml file and RSS feed using ASP.NET and C#. The following is the webpage to get the popfly project. http://www.popfly.com/users/370203/WebSiteXML.details It is test on Visual Web Developer 2005 Exprss Edition.

Problem with MDB file in Asp.Net application

I have been using Microsoft Access database to store some infrequently changed information for quite some time. It worked well until recently I began to use GoDaddy Hosting plan. I uploaded my application to my GoDaddy hosting server, made some changes online, and downloaded to my local development environment because I noticed that the online change did not work as I expected. With some debug, I found that I got a strange exception with all update SQL statement. System.Data.OleDb.OleDbException was caught Message="Operation must use an updateable query." Source="Microsoft JET Database Engine" ErrorCode=-2147467259 StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCom...

Send Email using ASP.NET by GoDaddy mail server

After transferring to GoDaddy from another Hosting plan, one of the major changes I have to make is the email function. Luckily I have all my email functionality in one utility class. In this class I attempt to use both methods to send email. Actually both should work. private static void SendEmailOut(string sTo, string sSubject, string strMessageText) { try { SendMailByWebMail(sSubject, sTo, strMessageText); } catch (Exception ee) { try { SendEmailByNetMail(sSubject, sTo, strMessageText); } catch (Exception ee2) { throw (ee2); } } } //method 1 Webmail public static System.Web.Mail.MailMessage CreateMailMessage() { System.Web.Mail.MailMessage newMessage = new System.Web.Mail.MailMessage(); newMessage.From = "Technique Support "; newMessage.Headers.Add("Reply-To"...

Lost Website domain name

Unfornately I lost my website domain name. I forgot to renew the domain and the next day I noticed my domain had been registered by ICANN. Sigh... The good thing is that I have planned to shift my website from Hostdepartment to Godaddy and now it is definitely the good time to do it. The first thing is to get a good domain name. It took me quite some time to make a decision on this issue. Then I canceled my original Economy hosting plan and bought a deluxe hosting plan. With a coupon altogether it cost me 60$. After 12 hours or so I was able to upload my website to my new domain. During the setup I noticed that GoDaddy is using web farm to host the websites because I made use of Application variables in my ASP.NET website. From time to time the request will trigger a Application varible loading function. I wished I had used other techniques instead of Application varible to hold global values. Fortunately most of my website functions do not depends on application variables. Therefore I...

Meta data of webpage

Yesterday I noticed that the search result of my website was displayed terribly in Google search. After some search and comparison, I realized that I had not put any meta data like "Key Words", "Description" to my web pages. "Key Words" does not means too much to Google, so far as I can tell. However, description is quite important as it might be shown in Google search result. The following are office Google blog to discuss the importance of the meta data. Answering more popular picks: meta tags and web search . and The meta element Yahoo also provides a guide line to design the key words meta tag. How should I write my keywords? Based on the suggestions, I finally added description and keywords to my web pages dynamically based on the web page content. The following article provides a method to add meta data to Asp.Net web pages using C#. Adding Meta Tags to the Head in ASP.NET 2.0 You can find a complete discussion from following link: Are repeated meta...