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

The Script Resource and the Web Resource files are generating intermittent errors in my application. I have been trying to chase the cause of the problem but to no avail. I notice that the “d” parameter that is passed is some how corrupted and I can’t for the life of me figure out what’s causing this parameter to be corrupted. I noticed that JavaScript code that in my application is some how getting intertwined with the hash code that’s generated for the “d” parameter.  

 

 

Exception genereated on Monday, January 26, 2009, at 12:06 AM
Page location: /ScriptResource.axd?d=70kBR-jPBTx9R89F Requested Url : http://panasonic.premiumstore.com/ScriptResource.axd?d=70kBR-jPBTx9R89F

Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
Method: System.Object _InvokeMethodFast(System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeTypeHandle)
Stack Trace: at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at System.Web.Handlers.ScriptResourceHandler.DecryptString(String s) at System.Web.Handlers.ScriptResourceHandler.DecryptParameter(NameValueCollection queryString) at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context) at System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Inner Exception: System.Web.HttpException: Invalid viewstate. at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) at System.Web.UI.Page.DecryptString(String s)
User IP: 206.255.110.126

BaseMessage : Exception genereated on Monday, January 26, 2009, at 12:06 AM
Page location: /ScriptResource.axd?d=70kBR-jPBTx9R89F Requested Url : http://panasonic.premiumstore.com/ScriptResource.axd?d=70kBR-jPBTx9R89F
Message: Invalid viewstate.
Source: System.Web
Method: System.String DecryptStringWithIV(System.String, System.Web.Configuration.IVType)
Stack Trace: at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) at System.Web.UI.Page.DecryptString(String s)
User IP: 206.255.110.126

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
It appears you are referencing an empty viewstate(object = nothing).

Try this....

If ViewState("VarName") ISNOT Nothing THen
'Do your stuff
TextBox1.Text = ViewState("VarName").ToString()
Else
'ViewState = Nothing
'Reset your viewstate...
SCOPE:  it is only good for the life of the PAGE....redirect to same page sets it to nothing
End IF

If this doesn't solve it, strip your code down and paste it in the forum and I'll see if I can help out.

Later

TallOne

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
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
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
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
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
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
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
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

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search