shubham maini
shubham maini

Reputation: 19

How to Delete the extra route value in Routing

Hi I hope you are doing well, I came across issue and I need your help there is page where the route is PartnerAdmin/Account/RetrievePassword and when i entered PartnerAdmin/Account/RetrievePassword/bla/bla then I can still see the same page what i need to do is whenever somone search for something extra in url that extra part needs to get delete and route on same page.

I tried

context.MapRoute( name: "Partner_default", url: "PartnerAdmin/{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional}
);

Upvotes: 0

Views: 43

Answers (1)

Eugene
Eugene

Reputation: 361

You can use redirect rule

    var options = new RewriteOptions()
        .AddRedirect("PartnerAdmin/Account/RetrievePassword/.*", "PartnerAdmin/Account/RetrievePassword");

    app.UseRewriter(options);

Here is the link to read more about it: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting

Upvotes: 0

Related Questions