Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created March 13, 2014 08:16
Show Gist options
  • Save netsi1964/9524154 to your computer and use it in GitHub Desktop.
Save netsi1964/9524154 to your computer and use it in GitHub Desktop.
Dynamicweb Razor redirect if missing PID
// Code snippet for request missing PID - say coming from Google search
@using System.Web
@using Dynamicweb.Frontend;
var request = HttpContext.Current.Request;
var response = HttpContext.Current.Response;
var pidFromRequest = Dynamicweb.Base.ChkString(request["pid"]);
var pageviewURL = GetGlobalValue("Global:Pageview.Url");
if (pidFromRequest=="") {
pageviewURL+= (pageviewURL.IndexOf("?")==-1) ? "?" : "&";
pageviewURL+="pid="+PID.ToString();
response.RedirectPermanent(pageviewURL, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment