The problem today, is that we have a great asp.net website but search engines are indexing the http://greataspnetwebsite.com instead of http://www.greataspnetwebsite.com, this is commonly seen on the web and there are several ways to archive a good result for making the non-www to www domain. This redirection should be a 301 Permanently Moved, otherwise you will might lose your search engine indexed page or become duplicate content for your non-www and www domain. Here are easy steps how to archive a quick and clean Permanent Redirection using IIS.
Consider the case where we already have a website in IIS called: greataspnetwebsite.com
Go to IIS Manager
Create a new website that point to the same directory as your existing one
Select the newly created website, open the properties box
In the option button “When connecting to this resource the content should come from” should be change to “A redirection to a URL“
Specify the URL http://www.greataspnetwebsite.com
Select the check box that says “A permanent redirection for this resource.”
This post relates how to Copy/Clone custom object in C# (Deep and Shallow Clone).
In this example I will be having a base class that all my custom object will be inheriting from.
Updates: After quiet some research on the subject i recently found some interesting articles on this subject and wanted to share them on this post.
Object Cloning Using IL in C#
This subject is inspired on a session I followed on the TechDays 2008,
that addressed the fact that IL (Intermediate Language) can be used to clone objects, among other things, and that it’s not evil at all, and it can be pretty performant also.
You only have to see that you don’t overuse it tho, because otherwise the readability of your code is reduced, which is not a good thing for the maintenance.
And wrong usage of reflection (what IL is, or at least uses) can also result in poor performance.
C# Class For Making a Deep Copy Clone of an Arbitrary Object
Here is a C# class that can create a deep copy clone of an arbitrary object. The thing that’s special about it is that it should work for any class that extends it, so that you don’t need to re-write a custom clone() function for every child class (as it seems the C# framework creators would like). This does a deep copy so be careful about members that recursively include one another.
Another way of doing this would be to use serialization . . . I just personally thought the reflection package would be more elegant.
Clone C# Object using Serialization and De-serialization (Deep Clone)
In this example i’ll be using Serialization and De-Serialization to make a deep clone of the Person Class.
You must import the following namespaces to start with.
Let’s create a base class Person that all our other classes with inherit from. It will contain the following methods:
ToXMLString() : Returns an XML version of the current object
Deserialize(XmlDocument xml, Type type) : De-serialize the current XMLDocument cast it to the current type
Serialize(object o) : Serialize the current object and outputs an XMLDocument
Clone(): Runs a Serialization and De-serialization and returns a clone of the current Object
public abstract class Person
/// To XML string.
public string ToXMLString()
XmlSerializer serializer = new XmlSerializer(this.GetType());
MemoryStream dataStream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(dataStream, Encoding.UTF8);
/// Deserializes an xml document back into an object
/// The xml data to deserialize
/// The type of the object being deserialized
/// A deserialized object
public static object Deserialize(XmlDocument xml, Type type)
XmlSerializer s = new XmlSerializer(type);
string xmlString = xml.OuterXml.ToString();
byte buffer = ASCIIEncoding.UTF8.GetBytes(xmlString);
MemoryStream ms = new MemoryStream(buffer);
XmlReader reader = new XmlTextReader(ms);
Exception caught = null;
object o = s.Deserialize(reader);
Was just trying to view one of my post that i modified once after being published and bumbed up with a page with these error messages:
Warning: ini_set() has been disabled for security reasons in /home/wacdesig/public_html/wp-includes/pluggable.php on line 1517
Warning: require_once(Text/Diff/Renderer.php) [function.require-once]: failed to open stream: No such file or directory in /home/wacdesig/public_html/wp-includes/Text/Diff/Renderer/inline.php on line 17
Fatal error: require_once() [function.require]: Failed opening required ‘Text/Diff/Renderer.php’ (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/wacdesig/public_html/wp-includes/Text/Diff/Renderer/inline.php on line 17
Apparently this is due to my hosting provider that have disabled the use the the PHP function ini_set(). Great !!! how do i edit post that i have edited before… fortunately i found out someone that came up with a solution :).
Please note that this issue is only for WP 2.6 and is cause by the new Revision module that allows you to view a revision of your post before it was edited.