Java script error when URL's modified in Application_EndRequest and Application_BeginRequest

W

Wayne Sepega

In our web application we have a routine that will take a URL and encrypt
the query string portion of it. We are doing this in the Global.asax in
Application_EndRequest, we have done this in 1.1 and I am currently using
the same code in my 2.0 application.

protected void Application_BeginRequest(Object sender, EventArgs e)
{
Response.Filter = new UrlEncryptFilter(this.Response.Filter); // Encypts
any URL on the page that has a query string.

if (this.Request.QueryString["eqs"] != null) //Check to see if the if the
request URL was encoded.
{
// Unencrypt the query string
string queryString = Decode(this.Request.QueryString["eqs"]); //Decode
the request query string
Context.RewritePath(this.Request.Path, this.Request.PathInfo,
queryString);
}
}

protected void Application_EndRequest(Object sender, EventArgs e)
{
if (this.Response.RedirectLocation == null)
return;

string oldUrl = this.Response.RedirectLocation;

int i = oldUrl.IndexOf('?') + 1;
if (i > 0 && oldUrl.Length > i + 1)
Response.RedirectLocation = string.Concat(oldUrl.Substring(0, i),
"eqs=", Encode(oldUrl.Substring(i)));
}


If this code is in place when I pull up some, not all, forms in my web
application I receive the following error in the browser:

Line: 915
Char: 1
Error WebForm_SaveS croilPositionSubmit' is undeFined
Code: 0
URL: http://localhost/LoadAlerts/Alerts_Add.aspx

Line 915 contains:
theForm.submit = WebForm_SaveScrollPositionSubmit;


This occurs even if there isn't any thing to be encrypted on the page. I've
taken the resulting page and saved the source both encrypted and not
encrypted, when there are no links on the page to be encyrpted the source is
identical.

Any help would be appreciated. Let me know if I need to supply any further
information.
Thanks
Wayne Sepega
 
W

Wayne Sepega

After much time, effort and help from a co-worker, we've found the issue.



ASP.net 2.0 generates the following in my web page:

<script
src="/LoadAlerts/WebResource.axd?d=S462ZtHX1VAIPXUpdJLd4Q2&amp;t=632663465369687500"
type="text/javascript"></script>


<script
src="/LoadAlerts/WebResource.axd?d=7eM4r3f83vmLH-iLPspbfw2&amp;t=632663465369687500"
type="text/javascript"></script>


I have this in my global ASAX in the on begin request:



Response.Filter = new UrlEncryptFilter(this.Response.Filter);

When the page is loaded the above Scripts are requested, for some reason yet
unkown, the java script is striped by our filter. I'm going to add an if to
make sure that the requested page has an .aspx extention.



Thanks

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top