In SharePoint 2010, I had a situation in which I needed to immediately redirect users to another page if landing on the first page. I knew about Meta Refresh in HTML and I knew about response.redirect in basic ASP.Net, so I was wondering how I could accomplish this.

The solution I came up with was a little different that what I wanted, but I saw that I could work with it. The main thing is to create a new Content Editor Webpart on the page, and copy some code which uses the html meta refresh tag.

Here’s the sample I found:

<script '"text/javascript"'>//<![CDATA[alert("This site has been moved to another location. 
    Please update all existing bookmarks. 
    You will be redirected momentarily.");//]]></script>
<meta http-equiv="refresh" content="10;url=http://yourURL">

In the sample I found, it had a refresh time of 10 seconds, and a message to display in the mean time. Of course, I wanted it to redirect immediately, so I changed the time from 10 to 0. The problem I had was that it still showed the page for a second or so, before it actually did the redirect. Even with it set at a higher second count, the alert never showed.

Unfortunately, when it was running, and redirecting, it was redirecting too quickly for me to actually go to Site Settings and then Edit Page and even though I didn’t like the original message, it didn’t matter because it didn’t show up anyway. But – I did need something on the page, because it was just a little klunky (IMHO) to have a blank page for a second and not know why (in the user’s perspective). So, I just created another Content Editor Webpart and put in ‘Redirecting….’.

That’s it!