views:

175

answers:

2

I am running into a bad request error 400 on IIS7. I have encoded special characters in the URL string. My URL's look something like this (doesn't like %26):

http://www.myjobs.com/a/q-Barnes+%26+Noble

This would be an easy fix if I were running on .NET 4.0, but I am on rackspace cloud and can only run on IIS7 .NET 3.5.

This is what I would use in my web.config if I were on IIS7 .NET 4.0:

requestPathInvalidCharacters=""

What other options are there when running on IIS7 and .NET 3.5?

A: 

The only way you can make requests like that is if you change the registry. For IIS running in 32 bit mode, add the following DWORD key and set its value to 1 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\VerificationCompatibility

If you're running IIS in 64 bit mode, add the following DWORD key and set its value to 1 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\ASP.NET\VerificationCompatibility

Not sure if your hosting enviornment will give you access to that stuff. I tested it on IIS 7.5 and was able to make a request to /Barnes&Noble/default.aspx using a URL encoded like this: Response.Redirect(Server.UrlEncode("Barnes&Noble") + "/default.aspx");

JaySilk84
A: 

Why encode special characters into the URL at all?

Why not convert them all to a more SEO-friendly form that has only alphanumeric characters and dashes and store that special form in your database. Or, even easier, include the ID in the URL and use the latter part just to make it human readable and SEO-friendly:

e.g. www.myjobs.com/a/1234/q-Barnes-and-noble

This approach also means you can change your encoding later (maybe add some new special character to alpha mapping) and not have any 404's.

Hightechrider