Implement PICS and P3P in ASP.NET headers

Mar 14, 2006

PICS (Platform for Internet Content Selection) and P3P (Platform for Privacy Preferences) are two really nice things to be aware of when developing web applications. If your website targets children, maybe you sell toys, you should know about products like NetNanny that blocks access to certain websites based upon a lot of parameters. It’s for the protection of children that parents install these website blockers to keep their youngsters from accessing websites containing violence, nudity etc.

That’s why the World Wide Web Consortium created PICS. You can then label your website with a set of codes that tell products like NetNanny about the content of your site. If you don’t label your website, you run the risk of being blocked by these kinds of products.

P3P is about securing the users privacy and for web developers it’s about the permission to set cookies on the user’s browser. Well, that and other things which are not important right now. Internet Explorer 6.0 supports it very well, which makes it a no-brainer to implement, since it’s the worlds most used browser. You could risk that a user does not accept your cookies and that could ruin his or hers experience on your site. If you are about to create third-party cookies, you definitely need a P3P policy.

It is normally quite cumbersome to creating P3P policy files and creating a PICS label from ICRA, but I’ve done it for your, so don’t look any longer. Just place this method in the global.asax file on your website and you're good to go.

Private Sub Global_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BeginRequest
  Response.AddHeader("P3P", "CP=""NOI DSP COR ADMa IVDa OUR NOR""")
  Response.AddHeader("Pics-Label", "(pics-1.1 ""http://www.icra.org/ratingsv02.html"" l gen true for ""http://" & Request.Url.Host & """ r (nz 1 vz 1 lz 1 oz 1 cz 1))")
End Sub

Remember, this is a quick fix – not the whole shebang, but it works. Enjoy.

* Only $4.95/month ASP.NET & Windows 2008 + IIS 7 Hosting! FREE SQL Included

Comments (2) -

 Barry Dorrans
Barry Dorrans
8/10/2006 2:57:03 PM #

You're assuming of course that you have access to edit global.asax, compile it up and drop it.

The method I showed at http://idunno.org/displayBlog.aspx/2006080101 that you criticised for being "very complicated" doesn't require such access, simply the dropping in for the http module (which I guess I should make available for download, and not just provide source) and the addition of the configuration information in web.config. Nor does the module method require a recompile every time your headers change, and once we all move to IIS7 when Http Modules are a part of the pipeline extensibility that sort of approach will be more common.

Each method has its own advantages and disadvanatges!

Mads Kristensen
Mads Kristensen
8/10/2006 4:40:16 PM #

Barry, you are absolutely right. If you don't have access to compile the ASP.NET 1.x projekt and the IIS, then you cannot use this method. But what are the chances of not having access to at least compiling your ASP.NET project?? If you use ASP.NET 2.0 you don't even need to compile, just upload the global.asax.

Comments are closed

About the author

Mads Kristensen

Mads Kristensen
Program Manager at the Microsoft Web Platform team and founder of BlogEngine.NET.

More...

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.