ScriptResource not loading - asp.net

This is an interesting problem...
I've got an ASP.NET 3.5 web application. It's relatively simple - a content page based on a master page, with a couple of usercontrols on the page.
There are a total of four controls on the page; two are custom controls and two are Ektron CMS controls.
For some reason, I've been getting 'Sys is undefined' Javascript errors. The Firebug error console also throws an "ASP.NET client framework failed to load" error. I can't figure out why this is happening.
The kicker - if I take the controls that don't work completely out of the content page, they work just fine. It's obviously something in the content page trashing the framework, but I haven't been able to figure this one out.
I've looked through several dozen articles before posting, including suggestions like:
Repairing the .NET framework (didn't work)
Various web.config tweaks (either already there or didn't work)
regiis -i command (I don't think this will help, since the controls do work when I'm not using the content page)
Commenting out custom scripts on the user controls (didn't work)
Commenting out the other user controls on the page (didn't work)
Create a blank page and drop only the control I'm interested in on the page (this actually works)
Has anyone seen something like this before? It's got to be something in that content page, but I'm struggling with what.
EDIT
I noticed while stepping through the code the UserControl's PAGE_LOAD event fires three times; on the third time the code throws an error. (I'm still trying to get my head around the error that's being thrown)
EDIT
I wanted to add this in case someone else sees this error. It turns out the problem was being caused by a Scriptmanager on the page template that wasn't needed.
When I took the Scriptmanager off the page, everything worked fine and the framework load error went away. I figure this problem must have broken other scripts and prevented them from running later on down the page.

If you get a 404 on ScriptResource.axd, there must be something wrong with your ASP.NET installation. I had this before, when I did not configure the correct ASP.NET pool. For instance: there could be another ASP.NET application on the same server assigned to the same pool, that is running under ASP.NET 2.0. You say your application runs under 3.5. Can you try iisreset on your machine and then start your application?
The pool could be assinged to the wrong .NET version.
Another option could be, that .NET 3.5 is not installed on the server at all.
Are you sure that the site runs well without your content page? ScriptResource.axd is a dynamic handler to generate JavaScript on the fly. If it's not available, the scripts cannot work.

Your use of Sys needs to be AFTER your ScriptManager is setup on the page. The ScriptManager is what instantiates the Sys object.

Related

How to override page render for an error page?

We have an ASP.NET MVC application, and when it encounters an error you are not redirected to an erro rpage, instead the content of that page is replaced with the content of the error page. You go fix your code and press refresh and you're done.
We have another application that's written in WebForms and I'd like to get the same behavior out of it. Right now the current behavior is that when an error occurs you get redirected to ~/Error.aspx. Is it possible to make webforms behave this way? Perhaps override the page render event somehow?
This is just for development right? Displaying the error.aspx on production is much better both from a security and user experience perspective.
In order to turn off custom errors, you need to know how to turn them on. Yes? There are several places custom errors can be configured.
in IIS Create a Custom HTTP Error Response (IIS 7)
an error handler on the page, in global.asax, or in a class defined elsewhere (app_code folder perhaps)
in web.config Web.config customErrors mode
Web.config is probably the most common place. Start there.

Classic ASP on IIS 7

I am having problems with my app running on IIS 7. The application is a mixture of classic ASP and ASP.NET MVC (don't ask how and why).
Anyway, the application is up and running except for some problems that I am experiencing. For example, I have a button on my page and when I click it, javascript is opening a popup which needs to contain .asp page. But that doesn't happen. I get the blank popup with my cursor on busy as it still loads. This is happening almost always to me in IE. In Firefox it is much better but sometimes the app jams there too.
If I close the opened, blank popup, and I want to move around the application, my buttons in menu (which are also .asp) doesn't load properly. For example, I have different buttons for different sections and when I move around they should change. When I restart the browser, only then everything works normal for some time, but the problem occurs again after a while.
I am very sure that it is not the problem in application itself, because it works properly on the machines of my colleagues without those problems. They have the same OS (Vista Professional) and we compared the settings in IIS and they match.
So I am very confused, and I really don't know how to solve the problem. I found a bunch of articles and blog posts about classic ASP and IIS7 but most of them are about enabling asp, which I already did.
So I am suspecting that something wrong with IIS, but I don't know what, tried to reinstall it, hoping for some improvement, but I had no luck.
If you need more details please ask.
Does anyone have any idea what should I try or do?
When debugging ASP.NET or ASP apart from the VS itself the most important tool you need is Fiddler (free tool from MS). This allows you to observe the http sessions the occur between your server and the client. This tool will give much greater visibility on what is actually happening underneath.
Next Step
So you now know that the problem is server side and the URL of the resource causing the problem. The next step is to debug the server side process by attaching to the w3wp.exe that is serving your site. If the resource specified by the URL is an ASP paged attach for script debugging or if its ASP.NET attach for Managed Code debugging. (Note for ASP debugging you will need to enable ASP server side debugging in the ASP settings in IIS manager).
You should place a break point on the first entry point of code for the resource. Now you can step through the code and discover where it is locking up.

asp.net MVC Routing Problem

Someone has asked me to look at their code to do a few little changes to the processing, but before I can get anywhere, I can't even run up the main page. It seems to be MVC, seems to have the right routes etc. It defaults to a ~/home from default.aspx and there seems to be a route in place, but I get a 404.
I've tried changing the route and it still fails. I've debugged and it seems to be setting the routes up. I've set up Phil Haack's debug utility but it still just gives me a 404.
I'm quite new to asp.net MVC, but I've done asp.net and know some MVC (CakePHP) and I'm not really working with the MVC, just some processing code. Are there any big "gotchas" I should be looking for?
There is a Default.ASPX page that is included in the root path by default in all ASP.NET MVC projects. It has a comment in it that says:
Please do not delete this file. It is
used to ensure that ASP.NET MVC is
activated by IIS when a user makes a
"/" request to the server.
You might want to check and see if it is still there.
Are you running the app on IIS 6? If so, the problem is that IIS only invokes ASP.NET when it sees a .aspx extension in the URL. This can be fixed in a number of ways, described, for instance, here and here. I solved the problem changing IIS options to use aspnet_isapi.dll for all files (that is, *).
The problem was that the project was built on asp.net MVC Preview, and I already had asp.net MVC v1 installed, which seemed to create some sort of conflict.
I've removed asp.net MVC and the problem has gone away.

ASP.NET Routing not firing when site is published to remote host

I have a website that was originally written in webforms to which I have added MVC functionality. When debugging locally it works fine, however, once published and uploaded to my host the routes do not work and return a 404.
I am pretty sure that I have uploaded all the correct files. Would just appear that routing is not working.
Any idea?!
(the site will still serve normal aspx pages fine)
I think the problem may be related to Mixing ASP.NET MVC into ASP.NET WebForms
But I cant see from that thread what the solution was. It looks like it might be something to do with the app_pool mode - but I am running in integrated mode, which is right AFAIK
UPDATE 2
So I think I have routing working. I basically created a new MVC app and went through theweb config file line by line and made sure I have everything I needed. Funnily, none of the tutorials online mention the correct additions you need to make. hey ho..
I have have another issue mind you...
When i load my mvc page I am greeted with the message:
The SessionStateTempDataProvider requires SessionState to be enabled.
I've added a line to web.config to enable sessions (wasn't aware they were off) and it still doesnt work.
UPDATE
I created a new asp.net MVC project and ended up going through web.config line by line and ensuring that everything that related to MVC was included in my hybrid app. Suffice to say that none of the guides mention all the settings that are required (i was using the book professional asp.net mvc 1.0). I then included the global.asax file which is not published and set up a route so that a request for / was not being caught by MVC. I also had to enable sessions in web.config.
And now it works!
Should I mark this question as the answer...not sure on the protocol here :)
I was going through the same thing because I deploy with compiled views. I don't know why but global.asax isn't included in the Release folder that I uploaded. I just figured it was compiled into one of the DLLs. I was getting 404 for everything so I tried uploading global.asax and the site came to life.

What can cause ASPNET AJAX page to revert to normal ASPX mode ? / UpdatePanel broken

I am using VS 2008 with a very simple UpdatePanel scenario.
But i cannot get UpdatePanel to work and cant seem to find out why
I have in fact reverted to a very simple example to validate it is not my code:
http://ajax.net-tutorials.com/controls/updatepanel-control/
In this example I click on either button and both text links update.
I dont get any errors, the page just behaves like a normal ASPX page.
What things do i need to check. I've been googling this for an hour and not found what I need.
Edit: Works in Visual Studio web server but not in IIS
If it's working locally, but not when deployed to a remote server, that usually indicates that you're using ASP.NET 2.0 and the ASP.NET AJAX extensions aren't installed on the remote server.
If it's a server you have administrative control over, you can download the installer here: http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&displaylang=en
If it's a web host, tell them to get their act together.
Another option would be to check your web.config. You could for example create an new Ajax enabled ASP.NET website from Visual Studio. This will generate a correct web.config. Copy over all non-ajax sections from your existing web.config and you're set. This worked for me.
-Edoode

Resources