I am designing a new dynamic site from a static site. I have the route all sorted but I have a question on my Action method.
Below is the code but when testing and looking at the headers that Firebug reports, if I take out the Response.End it is a 302 redirect I assume because I set the 301 but then call another action which makes it a 302, but if I put in the Response.End I get a 301.
I am guessing that adding the Response.RedirectLocation is actually doing the 301 redirect so do I therefore change my return value to EmptyResult or null even though that line of code will never get executed just so the app compiles?
public ActionResult MoveOld(string id)
{
string pagename = String.Empty;
switch (id)
{
case "2":
pagename = WebPage.SingleOrDefault(x => x.ID == 5).URL;
break;
}
Response.StatusCode = 301;
Response.StatusDescription = "301 Moved Permanently";
Response.RedirectLocation = pagename;
Response.End();
return RedirectToAction("Details", new { pageName = pagename });
}