Suppose I wanted to create multiple websites hosted on different servers, but I want some certain duplicate contents (e.g. news box that shows same headlines and news on both sites). The sites will be different, just the news box will have duplicate contents. What would be the best approach for this? I'm just thinking duplicating user control that pulls data off the same database or is this too noob?

Recommended Answers

All 4 Replies

There are many ways to accomplish this however I'm not sure what resources you have at your disposal. You could use a central database, RSS Feeds or even an HTTP Post to obtain the desired content from a page that has the content the domains need to display. Any of these could be wrapped into a user control. What flavor of .NET are you using (C#, VB)?

Kenny

Here is a small example of an HTTP Post. You could build this into a user control which you could drop onto any page on any domain. The url below in the code "http://www.somedomain.com/UniversalContent.aspx" should be replaced with a page or text file that holds the content you want to be used on any of the other domains. You could then even add a property to the control to define what content it pulls.

public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(httpPost("http://www.somedomain.com/UniversalContent.aspx"));
        }

        string httpPost(string url)
        {
            System.Net.WebClient web = new System.Net.WebClient();

            web.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            byte[] parameters = {};
            byte[] results = web.UploadData(url, "POST", parameters);

            return System.Text.Encoding.Default.GetString(results);
        }

    }

Does this make sense? Like I said before there are many ways to do this and this is just one quick easy way. I personally use a shared SQL server for this kind of a thing but it depends on what resources you have available. Let me know if it works out.

Thanks,
Kenny

Awesome, Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.