W3C Validation Not working for RazorView

2019-08-15 16:30发布

问题:

I am using MVC4 project and doing URL rewrite on Server side in RouteConfig and appending .html at the end of url of every page..

www.mysite.com/home.html

I have couple of pages and those pages are linked with home page (every think is working find in browser).

But when I validate using W3C link checker, I get broken link error message.

I really don't know what can be issue. One more thing if I replace .html with .aspx or any other extension it is validated by W3C. I don't know what is issue.

My code is:

 routes.MapRoute(
                name: "features",
                url: "features.html",
                defaults: new { controller = "Home", action = "features", page =    UrlParameter.Optional }
            ); 

Web.config:

<add name="HtmlFileHandler" path="*.html" verb="GET" 
     type="System.Web.Handlers.TransferRequestHandler" 
     preCondition="integratedMode,runtimeVersionv4.0" />

Any help is highly appreciated

回答1:

Ok I solved it some what like this.

I replaced

<add name="HtmlFileHandler" 
     path="*.html" 
     verb="GET"
     type="System.Web.Handlers.TransferRequestHandler"
     preCondition="integratedMode,runtimeVersionv4.0" />

in webconfig with

<add name="HtmlFileHandler" 
     path="*.html" 
     verb="*" 
     type="System.Web.UI.PageHandlerFactory" />

and it works ... my page is validated by W3C now. :)