Matthew Matthew - 1 month ago 9
ASP.NET (C#) Question

<rewrite> not a valid child of <system.web>?

Hopefully I am just overlooking something incredibly simple, if so I apologize....

I have an ASP.NET application in .NET4 and we're trying to use URL rewriting using

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule....>


For some reason intellisense is returning an error which says that
<rewrite>
is not a valid child element of
<system.webserver>


When I build it and run it, it says something akin to "Error at line 0 in web.config"

If I remove all the
<rewrite>
lines it works properly (but of course no rewriting)

Is there a switch I need to flip on or something? It has to be something I'm stupidly overlooking....

Thanks

EDIT: Turned out IIS was borked. Vote to close.

Answer

Did you make sure you're targeting Framework 4.0?

<compilation targetFramework="4.0"/>