开发者

"Sys is undefined" error because WebResource.axd is returning the wrong content

开发者 https://www.devze.com 2023-03-05 17:33 出处:网络
I\'m getting the dreaded \"Microsoft JScript runtime error: \'Sys\' is undefined\" error while trying to develo开发者_开发问答p a site in ASP.NET on .NET framework 4.0.This was working fine until I tr

I'm getting the dreaded "Microsoft JScript runtime error: 'Sys' is undefined" error while trying to develo开发者_开发问答p 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}")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号