ASP.Net MVC route to catch all *.aspx requests

后端 未结 3 2110
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 22:19

This must have been asked before, but after reading here, here, here and here I can\'t extrapolate the relevant parts to make it work. I am revamping an old web fo

3条回答
  •  生来不讨喜
    2020-11-27 22:33

    Since my situation I only had a few main pages, with cockamamy rules, I found this easier.. To create an "oldaspxcontroller". So I can be sure everything mapped correctly.

    //https://www.oldsite.com/topics/travel/page9.aspx
    [HttpGet]
    [Route("/topics/{topic}/page{oldpagenum}.aspx")]
    public LocalRedirectResult TopicWithPage(string topic, string oldpagenum)
    {
    
        return LocalRedirectPermanent($"/topics/{topic}?p={oldpagenum}");
    }
    

    You may notice I still use pagenum in querystring.. I just think it looks better.. like mysite.com/topics/travel?p=9 I like better than mysite.com/topics/travel/page/9. I am in .Net core 3.1 and it works nice, even recognizes the pattern and the pagenumber..

提交回复
热议问题