If you are using URL rewriting you might know that you have to take care about the way you reference resources has written in the Scott Guthrie post; Tip/Trick: Url Rewriting with ASP.NET:

Handling CSS and Image Reference Correctly

One gotcha that people sometime run into when using Url Rewriting for the very first time is that they find that their image and CSS stylesheet references sometimes seem to stop working. This is because they have relative references to these files within their HTML pages - and when you start to re-write URLs within an application you need to be aware that the browser will often be requesting files in different logical hierarchy levels than what is really stored on the server.

For example, if our /products.aspx page above had a relative reference to “logo.jpg” in the .aspx page, but was requested via the /products/books.aspx url, then the browser will send a request for /products/logo.jpg instead of /logo.jpg when it renders the page. To reference this file correctly, make sure you root qualify CSS and Image references (“/style.css” instead of “style.css”). For ASP.NET controls, you can also use the ~ syntax to reference files from the root of the application (for example:

This is for sure also the case for javascript.

I am using the Request.PathInfo way described in Scott’s post to rewrite one url on Tech Head Brothers. Everything works fine except that Sys.Services.AuthenticationService get confused about the rewriting of the URL and tries to post back on :


When I expect


Looking at the page rendered by ASP.NET I see that the following is rendered:

So I am clearly missing a / in the path and due to that the URL rewriting confuse the post to the server.

The first solution was found by Cyril Durand (always of good help in this AJAX world ;) and is to add this line of code:

ScriptManager.GetCurrent(Page).AuthenticationService.Path = “/Authentication_JSON_AppService.axd”;

But I did it a bit differently, directly in the javascript adding the following line:


Btw this javascript line would be generated at rendering time by the solution of Cyril.

Thanks Cyril for the always nice talks.