Report updated with new information.
My initial report concerned an asp.net site / app, with vb.net codefiles, that only seems to work properly when debug is set to true in web.config. When debug=false the search function and the links to create a new search (which simply hyperlinks that reload the page) will occasionally not work, leaving the page partially loaded or not loaded at all.
From further investigation, it appears as though Page_Load is only being occasionally called, as I have a search object defined there that is occasionally found to be null (leading to the problems I've seen) in my button_click event (the first method that I find called when I refresh the page after a search).
Not really sure what to make of this or how to begin solving it. Have not found much of anything that suggests others have had the same problem. Any help appreciated!
I thought it might have been caching. Tried the suggestions here to no avail. I also discovered the setting of the debug flag is a red herring... having it set to true only masks the problem for a while, whereas setting it to false makes it appear almost immediately.
Check whether the user running the web page is having administrator rights .If not see whether the issue existing when running as an admin.
Try to run from a different browser .
Related
I have an ascx. In this ascx, I have any number of controls that I can interact with and set a session variable and it works as expected.
However, when (in the same control), I try to set session in page load, I get a different error depending on how I implement it:
System.Web.HttpContext.Current.Session("Test") = "Test"
It says that, summarized, the Session object is nothing.
If, instead, I say:
Session("Test") = "Test"
It then tells me that I need to enable session state in either the page or web.config. I have indeed checked and session is enabled in the web.config and furthermore, those session statements that are called in response to a click on a runat="server" control works fine.
At this point, I'm almost certain that my issue is because I lack knowledge on the lifecycle of the page and session object. So I therefore have two questions:
Why isn't this working as I expect? I suspect that I'm trying to call Session before some other code which makes it available is executing but what might that be?
How can I make it work so that I can store information in a session variable on page load (and subsequently clear it on page unload)? If I cannot make this work as I hope, how can I do something similar server-side?
The problem was caused by having multiple tabs in the same browser open.
To clarify...
Say maybe tab 1 is open to the page before where I tried to set session because I'm debugging and lazy and didn't close other tabs.
And then maybe tab 2 is the current tab that just opened when I started debugging. The only code change is where I'm trying to set a session variable.
There are now two tabs open with conflicting session state data. When the current code tries to set session, it is in conflict with what is being sent back and forth to "wherever sessions live". Or maybe it doesn't really work that way but closing the old tabs opened with "older code" and having only tabs opened that face the "new code" solves the problem.
Yes, the famous "'Sys' is undefined" Microsoft JS issue.
I've already done about 4 hours of digging and trying every suggestion I can find about it, so before you immediately call this a duplicate, here me out please.
Ultimately, this question is exactly the same as this one, but the accepted answer isn't relevant to my situation, and the OP is no longer an active member.
Background
There are about a hundred pages in this application. Each of them ultimately inherits from the same base class. This base class overrides the Init method and dynamically adds a ScriptManager to it as the first Form control.
On one single page out of them all, I encounter the issue described in the post I linked. I mentioned that the accepted answer was relevant. Here's why:
I'm not making any Sys. calls
My page doesn't have any AJAX-enabled controls on it
My page doesn't have any JavaScript on it
My web.config is accurate, it includes the proper handler entries
The issue is reproducible on both IIS 6.0 and IIS 7+
If I explicitly add a ScriptManager to the page via <asp:ScriptManager />, the ScriptResource.axd include still doesn't render to the output page
I've tried clearing browser history, Temporary ASP.NET Files, rebooting, etc. with no change in behavior
An older version of the application in our UAT environment functions correctly; the base page code nor the web.config file have changed since then
I'm completely stumped. It's an ASP.NET 3.5 web site project running on Win Server 2003 with IIS 6.0 (both Prod and UAT). My developer environment is Win7 with IIS 7.5. Same behavior in both environments.
Question
Does anybody have any ideas? I'm starting to think it's a bug in the ASP.NET 3.5.1 framework...
I've just had a similar issue that I seem to have just resolved.
IF you are overriding any other page lifecyle events on your page other than PageLoad make sure to trigger the base version of the event. E.g. I was using OnPreRenderComplete
protected override void OnPreRenderComplete(EventArgs e)
{
base.OnPreRenderComplete(e); //ADDING THIS LINE FIXED THE PROBLEM
//Add THEAD etc to Gridview
if (gvQueue.Rows.Count > 0)
{
gvQueue.HeaderRow.TableSection = TableRowSection.TableHeader;
}
}
Since you have tried everything else, and because it is reproducible, I can think of 3 possible causes that you can check:
1) The element not being defined correctly.
Make sure that the head element has runat="server" specified. We always provide an id as well, although I don't think that is strictly required:
<head id="HEAD1" runat="server">
2) The code that is causing the exception is being executed prior to the inclusion of the ScriptResource.axd.
To verify whether this is the case or not, I look at what has loaded in the page so far when the exception occurs. If I don't see the resource that is being reported as missing, I know I have an ordering problem.
I have seen this caused by two hooks of Page.Init (or other methods) in the inheritance tree and when this occurs, you cannot guarantee an order of execution.
3) An invalid page structure.
I have seen numerous cases where a misplaced, easily overlooked character, such as a single quote, double quote or < silently wrecks the page or javascript structure.
To verify that this is not the case, I first validate the page in design mode (Edit, Advanced, Validate Document) and correct any errors.
If there are no errors in design mode, I validate the rendered page by copying the source of the rendered page into an empty page within the project and then validating. This process has caught more than one subtle issue in the page structure.
4) If none of the above solve the problem, there could be an issue with the framework. If there is, it could possibly be caused by element names or order in your page. You can try removing or reordering items in your page until the problem goes away.
Hope this helps.
I don't really know where to start with this one. I am getting:
`Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.`
after moving a website to a new server. The exact same code works on my other server. It happens when I submit one of my forms (but doesn't do it on all form submissions).
Any ideas what can cause this so I have somewhere to look?
Using: ASP.NET 2.
EDIT: I am adding some user controls to a placeholder dynamically at runtime but this same code is working ok on my other server. I have tried clearing the controls in the place holder before adding new ones (as I saw a post about that) but it hasn't helped.
EDIT2: It seems that the postback is just failing. It isn't going into the onClick code of the button either so something is deffintiely screwy .. If I try / catch the exception it seems that all the controls are still added successfully ... Setting my Dynamic UC's to EnableViewState = false resolves this particular error.
EDIT3: Ok, I think I may have a handle on what is happening. For some reason on the old server the form action is default.aspx?action=amend but the new server is showing amend.html?action=amend so I think the re-write module is messing up in IIS. This would explain the control adding issue as well because the action is happening 2 times (I think). I will look into the Rewrite module and see if anything is wrong then post back.
Please, have a look at these articles:
http://blog.typps.com/2008/01/failed-to-load-viewstate-typical.html
http://weblogs.asp.net/guys/archive/2004/12/05/275321.aspx
Or try a simple temporary solution - disable viewstate for this placeholder. Either way, I'm puzzled why it actually works on your first server. I'd be glad if someone else will be able to clarify this subject more.
It turns out that the post back Url for the form is wrong on this server (unsure why at the moment, I will update when I know). This is causing the dynamic controls to be added in an unexpected way and causing the error. I noticed this when I managed to post my form and the content didn't update. I manually adjusted the action url using firebug and all is well.
Worth looking at walther's answer regarding dynamic controls and the viewstate though.
Not sure what caused it but I am manually setting the form action in the page load now and it seems to have solved the issue.
I having an issue with the ASP.NET Treeview control. I create the treeview just fine but the nodes will not expand or collapse. I see there is a javascript error but it is for line 1 character 0 of the webpage, there is nothing at line 1 character 0.
I am using the ASP:Treeview control in conjunction with the Telerik controls, but I'm not sure if that is an issue.
I saw there was a similar question here but the answer is not pertinent to my site. Has anyone run into this issue before? I've tried searching Google and tried a number of proposed solutions but so far none have worked.
Thank you,
Normally with problems like this it is best to isolate the code which is causing the problem. For example, create a minimal page with no other controls or external JavaScript and see if the problem persists.
It's also useful to use a decent debugger. The latest IE8 actually has a very good Visual Studio-style JavaScript debugger built in - go to your page, hit F12 and the go to the Script tab and click 'Start Debugging' and see where that leads you.
I've seen unhelpful javascript errors when a page does an AJAX postback, an exception occurs on the server, and the client javascript is unable to handle what the server returns. You could ascertain if this is happening by debugging the site, putting a breakpoint on the Page_Load method (or something similar), and see if it gets hit when trying to collapse or expand the TreeView.
I'm hoping someone has seen this before because I can't for the life of me find the problem.
I'm trying to do the old "fix the back button" thing in an application and I think i have a pretty decent approach, the problem is that it relies on the application not calling page_load when you hit back and instead loading the cached version of the page.
On about 60% of my pages that's exactly what happens. It loads the cached version and all is well. On the other 40% when i hit the back button page_load calls, forcing a refresh. For reference the call to page_load is NOT in a postback.
Even stranger is that this only occurs in IE (6 & 7). In firefox page_load never gets called.
I am using ASP.NET Ajax framework on both types of pages. Anyone seen anything like this before?
--Update--
After investigating a bit more I'm finding out that when i use the search to navigate from one page to another the application behaves differently for different pages. On the broken pages the page_load gets called twice, the search gets called twice and in fiddler that turns into 2 different redirect postbacks the second of which has no-cache set.
On the working page page_load and search only happen once and it immediately redirects.
That second Response.Redirect is causing the issue. Still not sure why that's happening though.
Check what the server is returning for the cache-control http header, then try setting Response.Cache.SetCacheability()/ use the output cache page directive on the pages and see if the server is saying that the pages should be cached.
if you are using ASP.NET AJAX why not using the History server control object?
replacing History, the back button will go to the link you want.
try this