locked
The url-routing changes the html relative links of the site RRS feed

  • Question

  • User1294719199 posted

    I saw a very good article about url-routing here: https://docs.microsoft.com/en-us/previous-versions/cc668201(v=vs.140)

    Ok now I'm doing url-routing in my site using:

    routes.MapPageRoute("blog", _
                "blog/{article_name}", _
                "~/blog.aspx")

    But a problem arised, every link now uses blog/{article_name}

    E.g. I have a link to a session called news.aspx

    Now the routes change every link of the page an it becomes: /blog/news.aspx

    I don't want the old links to be changed.

    E.g. If I have a link:

    <a href="newstest.aspx" >News Test</a>

    the link will actualy call:

    /blog/newstest.aspx

    Why that? I'd like the link to be on the root not on /blog/newstest.aspx

    Tuesday, December 11, 2018 10:58 AM

All replies

  • User839733648 posted

    Hi felchs,

    You should know the parameters of the .MapPageRoute() clearly.

    "blog"//The name of the route.
    "blog/{article_name}"//The URL pattern for the route.
    "~/blog.aspx")//The physical URL for the route.

    And the physical path may affect the last Url.

    If your page's path is under the route's folder, the url may contain the route's name.

    You could check that if your newstest.aspx page is under the folder blog.

    And I suggest you could change your code to:

    <a href="../newstest.aspx" >News Test</a>

    This will be back to the root directory.

    Best Regards,

    Jenifer

    Wednesday, December 12, 2018 10:09 AM