protected void Application_BeginRequest(object sender, EventArgs e) { // If the requested file exists if (File.Exists(Request.PhysicalPath)) { // Do nothing here, just serve the file } // If the file does not exist then else if (!File.Exists(Request.PhysicalPath) && !Request.PhysicalPath.Contains("WebResource.axd")) { //var x = Request.FilePath.Remove(0); string profilename = Request.FilePath.Replace("/", string.Empty); // Get the URL requested by the user // string sRequestedURL = Request.Path.Replace(".aspx", ""); // You can retrieve the ID of the content from database that is // relevant to this requested URL (as per your business logic) int nId = 0; ////// nId = GetContentIDByPath(sRequestedURL); \\\\\ // The ShowContents.aspx page should show contents relevant to // the ID that is passed here string sTargetURL = "~/profile.aspx?ProfileID=" + profilename;// +nId.ToString(); // Owing to RewritePath, the user will see requested URL in the // address bar // The second argument should be false, to keep your references // to images, css files Context.RewritePath(sTargetURL, false); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)