开发者

Resource.axd Syntax Error

I am using URL Rewriting with a ASP.NET website that doesn't use MVC. The site has been working fine and I have had no issues until today when I started to receive 2 errors. According to FireBug, both errors are on line 3 of WebResource.axd. That is the first line of code in the files and the line only has this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

How do I solve this? It doesn't much sense to me.

Also, I am using RouteCollection and IRouteHandler. The site I used to guide me was https://web.archive.org/web/20201205221404/https://www.4guysfromrolla.com/articles/051309-1.aspx. The only real changes I made was I added 2 more links in my page that I have not created routes for but I never clicked on either of those links.

I have since fixed my 2 links and the page was working fine for about an hour and then it started to the throw the error again and this time there seemed to be no rhyme or reason to it. My biggest issue is that it doesn't make any sense. A syntax error on the first line seems like an odd error.开发者_开发技巧


After much digging and research I figured it out! I just had to add this code to my my RegisterRoutes.cs file:

routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));

I found the answer at http://msdn.microsoft.com/en-us/library/cc668201.aspx. It doesn't really explain it but after doing some digging I realize what my issue was. It was replacing the code in my webresource.axd file, which is generated by IIS7, with my default not found page NotFound.aspx. While the above code would seem to break things it actually fixes it by stopping the linked code from being overwritten

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜