core razor legacy url rewrite in Startup.cs (default.asp => /index/... RRS feed

  • Question

  • Hello,


    like to rewrite a legacy url (default.asp?pageid=A) in .net core web using startup.cs, there: 

                    .AddRazorPagesOptions(options =>
                    options.Conventions.AddPageRoute("/newpath/GrabLegacyUrlPage/", "/veryoldpath/default.asp?pageid=10&p=2");


    These varies cause 404 error too:

    options.Conventions.AddPageRoute("/newpath/GrabLegacyUrlPage/", "/veryoldpath/default.asp?");

    options.Conventions.AddPageRoute("/newpath/GrabLegacyUrlPage/", "/veryoldpath/default");

    options.Conventions.AddPageRoute("/newpath/GrabLegacyUrlPage/", "/veryoldpath/"); is working, but - as you may imagine - not for the default.asp deeplink.

    Running out of ideas, asking kindly for help. Anoyone out there who fixed it?

    • Moved by CoolDadTx Wednesday, April 1, 2020 1:17 PM ASP.NET related
    Sunday, March 22, 2020 10:52 PM

All replies

  • Hello,

    Please use the following forum


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Sunday, March 22, 2020 10:57 PM

    I don't see how a legacy default.asp applies to Razor pages that uses the MVC pipeline. I  don't think what you are trying to do is going to work.

    Have you talken any Razor pages tutorial to understand Razor pages basics?

    The 404 means not found. It can't find the route to an Action method on a Razor page, becuase default.asp is not a Razor page.

    As already mentioned post to ASP.NET forums.

    Sunday, March 22, 2020 11:10 PM
  • Hi, yes i thought i understood razor basics.

    Incidently found out, that some web pages out there still referring a "once-upon-a-time-active" url "domain.toplevel/default.asp?pageID=10". Try to redirect them to the new page url (which is domain.toplevel/newvirtualdir/.


    Friday, March 27, 2020 12:04 PM
  • Hi Jonas,

    So, is the problem solved now?

    If so, you can mark your reply as an answer to help other members quickly find a solution when other members encounter similar issues.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 30, 2020 1:17 AM