简体   繁体   中英

IIS / ASP.NET Ajax failed to load

I have one project made a few weeks ago that is running perfectly and when i tried to copy the website to the final place it started showing this error.

Uncaught SyntaxError: Unexpected token < ScriptResource.axd:3
Uncaught SyntaxError: Unexpected token < ScriptResource.axd:3
Uncaught Error: The structure of ASP.NET Ajax client failed to load. VM5538 home:47
Uncaught SyntaxError: Unexpected token < ScriptResource.axd:3
Uncaught ReferenceError: Sys is not defined

The thing is, i only get this error on the website in the new folder, if i try to open it using the Visual Studio at old place i get no error.

I have already tried to create a new project in the final folder from scratch and put my files and i continue to get it.

I think it might be web.config/IIS related but i can't find what's wrong.

Thanks in advance.

I had this problem, and in my case it was caused by having a default Route defined. Fixed by adding an ignore rule before the default, like so:

   routes.Ignore("{resource}.axd/{*pathInfo}"); // this is the fix!

   routes.MapPageRoute("StandardRoute", // default route
       "{*value}",
       "~/Default.aspx");

More here: http://blog-rat.blogspot.co.uk/2011/04/url-routing-causing-to-load-loginaspx.html

You could try any of the below solutions and see if it fixes your issue.

1. You may need to add this under <httpHandlers> of <system.webServer> in web.config file

<system.webServer>
   <httpHandlers>
     ....
    <add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
   </httpHandlers>

</system.webServer>

2. It may likely that the .axd extension is not defined in the virtual directory mappings. Go to IIS manager to the properties of the virtual directory, click on the Configuration button, select the Mappings tab. You have to have the . axd extension defined to open with aspnet_isapi.dll. Uncheck Check that file exists checkbox as WebResource.axd and ScriptResource.axd are not actual files. The navigation options might defer depending on the version of IIS you're using.

3. Create an empty .txt in the application root and rename it to ScriptResource.axd

I managed to fix the problem by rewriting my rules in a different order. It was because i have this different URL schema and my web.config was messing something on the verification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM