I\'m trying to create something similar to the diggbar.
I\'m using Visual Studio 2010 and Asp Development server.
However, I can\'t get the ASP dev server
From Stefan on the ASP.Net team: http://forums.asp.net/p/1431148/3221542.aspx
In current versions of ASP.NET Urls containing characters like the colon character will be rejected as a potential security threat. The historical reason for this is that the underlying NTFS file system supports alternate resource streams that can be accessed with names like "yourfile.txt:hiddendata.txt". Blocking the colon character from Urls prevents poorly written applications from accidentally working with alternate resource streams.
There is also a limitation in current versions of ASP.NET that incoming Urls need to map to the NTFS file system for purposes of determining managed configuration data.
In ASP.NET 4 these limitations can be optionally removed. However these changes are in the Beta 2 version of ASP.NET 4 - they are not in Beta 1. We tried out the Url listed earlier in this forum post and confirmed that with our internal builds of ASP.NET 4 you can use that style of Url and process it without any 400 error.
-Stefan
A quick solution for development environment:
Change Web project properties to "Use IIS Local Server" and check "Use IIS Express" (which preserves the URL of VS Dev Server).
Add the following setting in Web.config inside <system.web>
:
<httpRuntime requestPathInvalidCharacters="" />
For production deployment, take into account the security considerations mentioned in other answers.
Try HttpUtility.UrlPathEncode(url)
- MSDN Docs
I'm not sure what web server digg is using but I'm betting this simply isn't possible with IIS or the built in web server for VS. Most likely it's a web server that can be modified to allow all sorts of wacky URLs.
I answered a similar question here.
https://stackoverflow.com/a/12037000/134761
Basically, ASP.net only accepts encoded characters such as colon after the question mark. Fortunately ASP.net MVC automatically maps both /api/persons/xxxx and /api/persons?id=xxxx equally in the default mapping, so that is what I ended up doing.
You need to use HttpUtility.UrlEncode on your string before redirecting to it.