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

Discussion in 'ASP .Net' started by Wayne Sepega, Jan 5, 2006.

  1. Wayne Sepega

    Wayne Sepega Guest

    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
    Wayne Sepega, Jan 5, 2006
    #1
    1. Advertising

  2. Wayne Sepega

    Wayne Sepega Guest

    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
    Wayne Sepega, Jan 6, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan

    Application_EndRequest

    Ryan, Jan 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,610
    Paul Glavich
    Jan 21, 2004
  2. Franck
    Replies:
    1
    Views:
    477
    Karl Seguin
    Oct 4, 2005
  3. tao lin
    Replies:
    1
    Views:
    3,770
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 26, 2006
  4. Mark Rae
    Replies:
    21
    Views:
    5,752
    ampitt02
    Jun 20, 2008
  5. SM
    Replies:
    0
    Views:
    943
Loading...

Share This Page