Today I was working on making SportsAlert valid against the doctype XHTML 1.0 Strict. I used http://validator.w3.org to test my homepage and fixed all of the issues except for 2. There are 2 issues inherent in ASP.NET web forms. One is that it adds name="aspnetForm" to the <form> tag, which is valid in XHTML Transitional but not XHTML Strict. Secondly, it adds input tags for things such as Viewstate right after the opening <form> tag, which is also valid in XHTML Transitional but not in XHTML Strict. To fix these 2 issues, you need to include:
<xhtmlConformance mode="Strict" />
In your web.config file within the system.web node. This will remove the name="aspnetForm" attribute from the <form> tag and will place the input tags within a div tag so that they have a valid container.
That should be enough, however for some reason the w3.org validator will still complain about these two things and when you look at the source code that it's pulling down, it's different from the real source code. The name="aspnetForm" will still be on the form tag and the input tags won't be wrapped in the div tag, when you can clearly see by doing view source on the page that those changes have been made. The solution is to add a .browser file to the App_Browsers directory in your ASP.NET application:
<browsers>
<browser id="w3cValidator" parentID="default">
<identification>
<userAgent match="^W3C_Validator" />
</identification>
<capture>
<userAgent match="^W3C_Validator/(?'version'(?'major'\d+)(?'minor'\.\d+)\w*).*" />
</capture>
<capabilities>
<capability name="browser" value="w3cValidator" />
<capability name="majorversion" value="${major}" />
<capability name="minorversion" value="${minor}" />
<capability name="version" value="${version}" />
<capability name="w3cdomversion" value="1.0" />
<capability name="xml" value="true" />
<capability name="tagWriter" value="System.Web.UI.HtmlTextWriter" />
</capabilities>
</browser>
</browsers>
I didn't take the time to figure out why this works but it does and my page is now XHTML 1.0 Strict valid, so I'm happy... :)
f2b34158-27b1-495a-8b1a-8929c97123fe|0|.0
I've been going through an SEO phase recently and part of that was renaming the aspx files of my ASP.NET 3.5 site to reflect the keywords and phrases i was trying to target. For example, a page called Services.aspx that might target web development services would be renamed Web-Development-Services.aspx. I noticed after renaming the files that I was getting errors because the search engines still had my old page names cached and these pages no longer existed.
To stop the bleeding, I had the customErrors node in my web.config redirect to my home page (this is not a solution!) Next I recreated the old pages (such as Services.aspx) and left them empty. Then in the code-behind of each I added some code:
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "http://mydomain.com/Web-Development-Services.aspx");
What does this do? When someone requests the old outdated url, it sends a 301 permanent redirect to the new url, which lets the search engine know to use the new page.
In .NET 4.0, there will be an even simpler way to do this:
Response.RedirectPermanent("~/Web-Development-Services.aspx");
Using one of these 301 permanent redirects methods you can easily keep users and search engines up to date on the structure of your site, even if you've renamed all of the pages for SEO purposes!
5eb4f8d9-b3c6-4782-a242-134f22b036e2|0|.0
This is my first post and I'm excited to start blogging!! It seems like every day I run into some sort of issue and once I figure out how to solve it, it makes me wish I had a blog so I could post the solution so that others won't have to spend as much time on it as I did.
This blog will be related to .NET development, and more specifically front-end web development. I used to consider myself an ASP.NET developer but I feel like we've come upon a crossroads. Straight ahead is ASP.NET, to the left is pure javascript development, and to the right is Silverlight. You look further down the ASP.NET road and see that there's another branch up beyond this one, ASP.NET going to the left and ASP.NET MVC going to the right. Which road to take??
a04ac8e8-43e3-4201-b745-2aa64cdb9119|0|.0