url rewrite help

Hi, i have one page like this:
http://localhost/app_g/Default.aspx?id=173&S=1&M=12

I want to be rewrite like this:
http://localhost/photos/173/1/12

how can i accomplish this changing my web.config file to do this. What should I change on the web.config file.
LVL 1
rafaelrglAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Edward ChoManaging Exciting Technology ThingsCommented:
0
rafaelrglAuthor Commented:
could you help me giving me one final solution to my problem, This link you show me is not working. can you provide me the syntax to add on web.config.
0
Edward ChoManaging Exciting Technology ThingsCommented:
You should have a web.config like the one below:

<rewrite>
  <rules>
    <rule name="Rewrite to Default.aspx">
      <match url="^photos/([0-9]+)/([0-9]+)/([0-9]+)" />
      <action type="Rewrite" url="app_g/Default.aspx?id={R:1}&amp;S={R:2}&amp;M={R:3}" />
    </rule>
  </rules>
</rewrite>

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

rafaelrglAuthor Commented:
i got this error:
Server Error

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
0
Edward ChoManaging Exciting Technology ThingsCommented:
What does the event log say?

I'm assuming you have IIS7 with ASP.NET role service enabled?  URL Rewrite Mod installed?
0
rafaelrglAuthor Commented:
Hi Edward, The page is like that:
http://localhost/app_g/Default.aspx?id=173&S=1&M=12
I want to be like this.
http://localhost/photos/173/1/12

Question, is your code doing the opposite
0
Edward ChoManaging Exciting Technology ThingsCommented:
Nope -- it is matching the second URL (via the "match") when the user types it in and the url rewrite mod translates it to the first for the server (basically so the server can understand the actual request).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rafaelrglAuthor Commented:
Hi, i found this on the internet that say i need to change the global.asax file like this, but it does not give errrors and does not change the path.

<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
    Sub RegisterRoutes(ByVal routes As RouteCollection)
        routes.MapPageRoute("test", "color/{id}/{*queryvalues}", "~/app_g/Details.aspx")
    End Sub
   
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
        RegisterRoutes(RouteTable.Routes)
    End Sub
0
rafaelrglAuthor Commented:
ok, now i am starting to understand this. If i access the link:        
http://localhost:4565/app_g/Details.aspx?id=2 it will not change to the other page i route, but it will stay at this addres. But if I access this addres: http://localhost:4565/color/2/ it will work as the same. But what about if I access the first link with the ?id=2, is there anyway to change to the friendly path.

RouteTable.Routes.MapPageRoute("test", "color/{id}/{*queryvalues}", "~/app_g/Details.aspx")
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.