R
Richard Priddy
Hello,
I have a webpage that uses URL rewriting to masquerade as many pages. I am
trying to get this page to work with ASP.NET2 web parts.
I will attach any important code at the bottom of this post.
The problem I am having is that when URL rewriting is enabled any controls
that are in WebPartZones cannot be moved minimized or closed. With URL
rewriting disabled all this is possible.
When the page loads and I logon to give me access to the design layout I get
3 JavaScript errors:
"WebPartManager is Undefined"
and two "WebPartManager is undefined" errors
I have been working on this for a number of hours and have been unable to
track down why these errors are occurring.
IHttpModule.cs:
public class UrlRewrite : System.Web.IHttpModule
{
HttpApplication _application = null;
public UrlRewrite() { }
public void Init(System.Web.HttpApplication context)
{ context.BeginRequest += new EventHandler(context_BeginRequest); }
public void Dispose() { }
private void context_BeginRequest(object sender, EventArgs e)
{
System.Web.HttpContext httpContext = HttpContext.Current;
String currentURL = httpContext.Request.Path.ToLower();
string processPath =
currentURL.Substring(httpContext.Request.ApplicationPath.Length).TrimStart('/').ToLower();
string physicalPath =
httpContext.Server.MapPath(currentURL.Substring(currentURL.LastIndexOf("/") +
1));
if (!System.IO.File.Exists(physicalPath))
{
string queryString =
httpContext.Request.ServerVariables["QUERY_STRING"];
string defaultPage = "~/Default.aspx?process=";
if (processPath.EndsWith(".aspx"))
processPath = processPath.Substring(0, processPath.Length -
".aspx".Length);
httpContext.RewritePath(defaultPage + processPath + "&" +
queryString);
} } }
Default.aspx.cs:
protected void Page_PreInit(object sender, EventArgs e)
{
if (!Request.RawUrl.Contains("WebResource.axd"))
{
System.Web.HttpContext httpContext = HttpContext.Current;
string RawURL = Request.RawUrl;
Regex regex = new Regex(
@"(?<URL>.*)\?",
RegexOptions.IgnoreCase
| RegexOptions.Multiline
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
Match URLMatch = regex.Match(RawURL);
if (URLMatch.Groups["URL"].Success)
{
RawURL = URLMatch.Groups["URL"].Value;
}
Context.RewritePath(RawURL);
}
}
I have a webpage that uses URL rewriting to masquerade as many pages. I am
trying to get this page to work with ASP.NET2 web parts.
I will attach any important code at the bottom of this post.
The problem I am having is that when URL rewriting is enabled any controls
that are in WebPartZones cannot be moved minimized or closed. With URL
rewriting disabled all this is possible.
When the page loads and I logon to give me access to the design layout I get
3 JavaScript errors:
"WebPartManager is Undefined"
and two "WebPartManager is undefined" errors
I have been working on this for a number of hours and have been unable to
track down why these errors are occurring.
IHttpModule.cs:
public class UrlRewrite : System.Web.IHttpModule
{
HttpApplication _application = null;
public UrlRewrite() { }
public void Init(System.Web.HttpApplication context)
{ context.BeginRequest += new EventHandler(context_BeginRequest); }
public void Dispose() { }
private void context_BeginRequest(object sender, EventArgs e)
{
System.Web.HttpContext httpContext = HttpContext.Current;
String currentURL = httpContext.Request.Path.ToLower();
string processPath =
currentURL.Substring(httpContext.Request.ApplicationPath.Length).TrimStart('/').ToLower();
string physicalPath =
httpContext.Server.MapPath(currentURL.Substring(currentURL.LastIndexOf("/") +
1));
if (!System.IO.File.Exists(physicalPath))
{
string queryString =
httpContext.Request.ServerVariables["QUERY_STRING"];
string defaultPage = "~/Default.aspx?process=";
if (processPath.EndsWith(".aspx"))
processPath = processPath.Substring(0, processPath.Length -
".aspx".Length);
httpContext.RewritePath(defaultPage + processPath + "&" +
queryString);
} } }
Default.aspx.cs:
protected void Page_PreInit(object sender, EventArgs e)
{
if (!Request.RawUrl.Contains("WebResource.axd"))
{
System.Web.HttpContext httpContext = HttpContext.Current;
string RawURL = Request.RawUrl;
Regex regex = new Regex(
@"(?<URL>.*)\?",
RegexOptions.IgnoreCase
| RegexOptions.Multiline
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
Match URLMatch = regex.Match(RawURL);
if (URLMatch.Groups["URL"].Success)
{
RawURL = URLMatch.Groups["URL"].Value;
}
Context.RewritePath(RawURL);
}
}