If you have control over the server, you must configure a virtual directory that accepts requests to "www.example.com" and redirects (301) them to "example.com"
While this is possible in ASP.NET MVC, redirecting this kind is not an ASP task.
On IIS: 
On Apache:
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / http://example.com/
</VirtualHost>
IIS and Apache settings will preserve the core URL.