URL Rewriting error : is not a valid virtual path

Sometimes this error occurs when you are doing some url rewriting with RewritePath method. One of the many possible reasons for this error is that assigning complete url path as a internal rewrite path. Therefore pass relative rewrite url path as a parameter to the RewritePath function instead of complete url.
For example, in the below given code, statement 1 will produce error where as statement 2 will work fine.

1. HttpContext.Current.RewritePath("http://localhost/TestSite/default.aspx");

2. HttpContext.Current.RewritePath("/TestSite/default.aspx");

4 comments:

Anonymous said...

Helped a lot!

Unknown said...

The resource cannot be found.

Requested URL: /actor/Manish-Vatsalya.aspx

jim smith said...

Very nice blog!
Transmissions Hollywood FL

Chiggy wiggy said...

Thanks for the latest update on bollywood.