IIS / ASP.NET Ajax failed to load

╄→尐↘猪︶ㄣ 提交于 2021-02-08 11:55:32

问题


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.


回答1:


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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/24873096/iis-asp-net-ajax-failed-to-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!