Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Script Resource and the Web Resource Issues


Script Resource and the Web Resource Issues

Author
Message
JamTech
JamTech
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 6, Visits: 15

I have been analyzing the data that I have been collecting and I have drawn a few conclusions. I noticed that a large majority of the errors that I have been getting are coming from windows Vista computers running IE 8 or Firefox 3. There where also a few cases where it was Vista and IE 7. This could explain why the errors are now just becoming an issue as more and more people are using the new operating system.

 

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; FunWebProducts; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GoogleT5; MSN Optimized;CA; MSN Optimized;CA)
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; GTB5; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0)

 

 

But anyways the conclusion that I want to get at is that based on this information I started looking into how the browsers process java scripts and if there was anything new that could be causing this issue, that’s when something interesting pop out at me, I found on the w3School website an article about the difference in html vs. xhtml.

 

Differences between HTML and XHTML

HTML 4 and XHTML deal different with the content inside scripts:

  • In HTML 4, the content type is declared as CDATA, which means that entities will not be parsed.
  • In XHTML, the content type is declared as (#PCDATA), which means that entities will be parsed.

This means that in XHTML, all special characters should be encoded or all content should be wrapped inside a CDATA section.

To ensure that a script parses correctly in an XHTML document, use the following syntax:

 So I immediately took a look into my code and I saw that the DOCTYPE directive was missing on some of my pages the sameones that are causing the Issue. I also noticed that where I was outputting JavaScript using the .NET Register Client Script routine it would wrap the inner content of the script tags with the CDATA attribute, while where there was the regular JavaScript written on the page there was no CDATA used. For example

 

<script language=”javascript”>

  Function RunMe() {

 }

 </script>

 

I am no expert on how browser’s renders or parse the html return, but I strongly believe it has some thing to do with the situation above because the Url parameter in the Script Resource request whenever it crashes always contains code in between script tags that's below it. Some times there is even html style sheet code that can be found there as well. For example

 

http://braun.factoryoutletstore.com/ScriptResource.axd?d=70kBR-jPBTx9R89FxObjhipHPS9CMlta5W6ZZiqkaa5zNOXUU4DtsY8V_8function runSearchForField(eventObj, id){    if ((eventObj.which == 13) || (eventObj.keyCode == 13))     {        var cat_gallery =  getParam('gallery');        var cat = getParam('cat')        var searchTerm = escape(document.getElementById(id).value); // must use escape() function to urlencode search term to avoid issues with '&' and '=' symbols        var url;            if (cat_

 

 

 

http://braun.factoryoutletstore.com/ScriptResource.axd?d=9vS7Hk65j_0hD8to_aPDj    <tr> <td class=

 

 

Now what am thinking is that some how because am not specifying any DOCTYPE in the page the browser might be trying to infer based on the data its receiving then it ends up messing up because sometimes there is CDATA and there are times when there is no CDATA present in the page. I don’t know really if this is a solid assumption cause as they say assumptions as dangerous. If anyone can shade some light on my theory and let me know if the browsers are parsing the xhtml differently that older version or even if they had any similar situations.    

JamTech

Bjorn Williams

bwilliams@gogotech.com

TallOne
TallOne
Forum God
Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)

Group: Forum Members
Posts: 370, Visits: 212

Replace exactly with this:

//Lawrence 4/17/2008: Perform search redirect when ENTER is pressed

//TN_Search_JS must exist as an HTML textfield on the page.

//Assumes that a global variable called  globalFullSubStoreUrl is already set.

TallOne

JamTech
JamTech
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 6, Visits: 15
That text is also located in that javascript code block, its part of the comment. The actual string is

/**

* Lawrence 4/17/2008: Perform search redirect when ENTER is pressed.

* TN_Search_JS must exist as an HTML textfield on the page.

* Assumes that a global variable called 'globalFullSubStoreUrl' is already set.

*/

The code that sets the variable runs in the code behind file. Shown below

Me.TN_Search.Text = getSearchValue()

Me.TN_Search_JS.Value = getSearchValue()

Me.TN_Search_JS.Attributes.Add("onkeypress", "return runSearchForField(event, '" & TN_Search_JS.ClientID & "');")

Me.TN_Search_JS.Attributes.Add("onfocus", "updateSearch('" & TN_Search_JS.ClientID & "');")

Me.TN_Search_JS.Attributes.Add("onblur", "updateSearch('" & TN_Search_JS.ClientID & "');")

Me.js_search_button.Attributes.Add("onclick", "runSearchForButton('" & TN_Search_JS.ClientID & "');")

'Lawrence 4/17/2008: Don't show loader since we are now using javascript redirect search.

'Me.search_loader.Attributes.Add("style", "visibility:hidden;")

'IMG_loader.Attributes.Add("onload", "hideme('" & Me.search_loader.ClientID & "')")

'CMD_Button.Attributes.Add("onclick", "showloader('" & Me.search_loader.ClientID & "')")

'------------------------------------------------------------------

'Lawrence 4/17/2008: Inject javascript code to show either javascript search redirect field/button

'or the .NET search postback field/button. NOTE: Because pressing ENTER using javascript field seems

'to cause the .NET javascript validation to perform a postback, Uri asked that any pages with this

'.NET javascript validation use the postback search field/button INSTEAD OF the javascript search field/button.

'This is why the if-statement below makes sure that the javascript code to display the javascript search field/button

'is only injected onto the outputted HTML if the URL does not contain "/shoppingcart/". (The shopping cart and checkout

'pages have the validation problem mentioned above.)

Dim objStoreDetail As New Gogotech.StoreDetails

Dim setDisplayOfSearchButtons As String = "function setDisplayOfSearchButtons() {"

If (Not Request.Url.AbsolutePath.ToLower.Contains("/shoppingcart/")) Then

setDisplayOfSearchButtons = setDisplayOfSearchButtons & _

"document.getElementById(""js_search"").style.display = ""block"";" & _

"document.getElementById(""" & Me.panSearch.ClientID & """).style.display = ""none"";"

End If

setDisplayOfSearchButtons = setDisplayOfSearchButtons & "}"

Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "setDisplayOfSearchButtons", setDisplayOfSearchButtons, True)

Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "varGlobalFullSubStoreUrl", "var globalFullSubStoreUrl='" & objStoreDetail.GetSubStoreUrl(objStoreDetail.Fetch_Substore(Request.Url().ToString())) & "';", True)

'------------------------------------------------------------------

I am currently going through the IIS web Log but this thing is hugh, I guessing it will take me sometime. Its over a GIG.

Hey thanks alot for the help again.

JamTech

Bjorn Williams

bwilliams@gogotech.com

TallOne
TallOne
Forum God
Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)

Group: Forum Members
Posts: 370, Visits: 212
I think it's somewhere else.  This js block looks ok.  Where is this text located?

"StoreUrl' is already set"

TallOne

JamTech
JamTech
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 6, Visits: 15
Here is a copy of the Javascript Code from the page, with the comments and all. I will start to Dig through the IIS logs to see what I can find.

<script type="text/javascript">

/**

* Lawrence 4/17/2008: Perform search redirect when ENTER is pressed.

* TN_Search_JS must exist as an HTML textfield on the page.

* Assumes that a global variable called 'globalFullSubStoreUrl' is already set.

*/

function runSearchForField(eventObj, id)

{

if ((eventObj.which == 13) || (eventObj.keyCode == 13))

{

var cat_gallery = getParam('gallery');

var cat = getParam('cat')

var searchTerm = escape(document.getElementById(id).value); // must use escape() function to urlencode search term to avoid issues with '&' and '=' symbols

var url;

if (cat_gallery != "")

{

//Redirect to gallery page.

url = 'http://' + globalFullSubStoreUrl + '/Category/CategoryListNoCache.aspx?category_id=0&g=gallery&search_term=' + searchTerm;

}

else

{

//redirect to listing page

url = 'http://' + globalFullSubStoreUrl + '/Category/CategoryListNoCache.aspx?category_id=0&search_term=' + searchTerm;

}

window.location = url;

return false;

}

return true;

}

/**

* Lawrence 4/17/2008: Perform search redirect.

* TN_Search_JS must exist as an HTML textfield on the page.

* Assumes that a global variable called 'globalFullSubStoreUrl' is already set.

*/

function runSearchForButton(id)

{

var cat_gallery = getParam('gallery');

var cat = getParam('cat')

var searchTerm = escape(document.getElementById(id).value); // must use escape() function to urlencode search term to avoid issues with '&' and '=' symbols

var url;

if (cat_gallery != "")

{

//Redirect to gallery page.

url = 'http://' + globalFullSubStoreUrl + '/Category/CategoryListNoCache.aspx?category_id=0&g=gallery&search_term=' + searchTerm;

}

else

{

//redirect to listing page

url = 'http://' + globalFullSubStoreUrl + '/Category/CategoryListNoCache.aspx?category_id=0&search_term=' + searchTerm;

}

window.location = url;

}

function updateSearch(id)

{

var searchField;

searchField = document.getElementById(id);

if (searchField.value == "") {

searchField.value = "Search";

} else if (searchField.value == "Search") {

searchField.value = "";

}

}

function getParam(arg)

{

var q = "" + window.location;

var c;

if (q.indexOf(arg) >= 0)

{

var pntr = q.indexOf(arg) + arg.length + 1;

if (q.indexOf(arg, pntr) >= 0)

{

return q.substring(pntr, q.indexOf(arg, pntr));

}

else

{

return q.substring(pntr, q.length);

}

}

else

{

return "";

}

}

</script>



JamTech

Bjorn Williams

bwilliams@gogotech.com
TallOne
TallOne
Forum God
Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)

Group: Forum Members
Posts: 370, Visits: 212
Make sure these tags /* have ending comment tags as well.  It appears like they don't with the way your js code is appending.

/*
Comments
*/

It appears that each time a visitor is hitting a certain piece of js code this is occuring.  Dig in your IIS log by IP to see the path they are taking to get the error.  You should be able to reproduce it...  That's the key!  I'm guessing your missing a  single apostrophe in one of the js functions.  Look in your js code above the function: runSearchForField

TallOne

JamTech
JamTech
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 6, Visits: 15
No. These are errors that visitors visiting the site are getting. I am just tracking the errors from the Global.ascx file.

I am not able to reporduce this issue.

JamTech

Bjorn Williams

bwilliams@gogotech.com

TallOne
TallOne
Forum God
Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)

Group: Forum Members
Posts: 370, Visits: 212
Are you using fiddler?

TallOne
JamTech
JamTech
Forum God
Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)Forum God (2.1K reputation)

Group: Forum Members
Posts: 6, Visits: 15

Hey Thanks a lot for you Help.

Ok this is what I have Notice in my analysis, the request for the script resource seems to be always intertwined with the same JavaScript code, I have included a line from my error log that shows the requested Url that caused the issue.

/ScriptResource.axd?d=70kBR-jPBTx9R89FxObjhipHPS9CMlta5StoreUrl'%20is%20already%20set.%20*/function%20runSearchForField(eventObj,%20id){%20%20%20%20if%20((eventObj.which%20==%2013)%20||%20(eventObj.keyCode%20==%2013))%20%20%20%20%20{%20%20%20%20%20%20%20%20var%20cat_gallery%20=%20%20getParam('gallery');%20%20%20%20%20%20%20%20var%20cat%20=%20getParam('cat')%20%20%20%20%20%20%20%20var%20searchTerm%20=%20escape(document.getElementById(id).value);%20//%20must%20use%20escape()%20function%20to%20urlencode%20search%20term%20to%20avoid%20issues%20with%20'&'%20and%20'='%20symbols%20%20%20%20%20%20%20%20var%20url;%20%20%20%20%20%20%20%20%20%20%20%20if%20(cat_gallery%20!=

as you can see the "d" parameter is corrupted. What happens here is that the System.Web.UI.Page.DecryptString will throw an Invalid view state error when it tries to decrypt this string. What I would like to know is how can this string become this corrupted.  I took a look at the JavaScript and everything seems ok to me, the only odd thing is that there are some comments in the code which is comment with /* to denote that the line are just comments.   

JamTech

Bjorn Williams

bwilliams@gogotech.com

TallOne
TallOne
Forum God
Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)Forum God (50K reputation)

Group: Forum Members
Posts: 370, Visits: 212
Opps misread your post.  Above post is not the issue! Sad

Strip your code down and post what is causing the issue and I'll take a look.

TallOne

Edited
1/26/2009 by TallOne
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search