jquery – Ajax call webmethod with friendly URL


I don't know if it's a frequent question, or something that isn't possible. During my studies I realized that it was possible to do this with PHP, but I didn't see anything with ASP.NET Web Forms.

I made a URL of the same page:

 routes.MapPageRoute("Pagina de Teste",

When I pass the page teste-usuario.com it loads teste.aspx .

My question is, I have an AJAX method.

            type: "POST",
            data: "objeto",
            url: "teste.aspx/metodoTeste",
            contentType: "application/json; charset=utf-8",
            dataType: "json",

Being metodoTeste my WebMethod and teste.aspx where this method is located.

I wonder if it's possible to pass my friendly URL (test-user.com) instead of teste.aspx to load the same page. I would not like to make the name of the page (test.aspx) visible.


Create a rewrite rule where .aspx suffix can be hidden.

Example (web.config):

   <rule name="Append .aspx">
        <match url="^((.*\/)?[^/.]+)$" />
        <action type="Rewrite" url="{R:1}.aspx" />

A page http://seu.site/teste.aspx can be accessed like http://seu.site/teste .

In the URL with parameters, using the question script as an example:

url: "teste.aspx/metodoTeste",

I would change it for this:

url: "teste/metodoTeste",
Scroll to Top