Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I need help with URL rewriting. I am new to ASP.NET Core MVC. When I type anything in {param} part then routing should redirect it to my controller.

So if anyone to types in {param} like

https://mydoamin.com/{param}

then it should be redirected to this url:

https://mydoamin.com/{controller}/{action}/{actionurl}={param}

share|improve this question

I could recommend you to see this blog post from Stephen Walther: ASP.NET 5 Deep Dive: Routing

share|improve this answer
    
I read the URL but not found exact result. Can you give me exact result. – vishal Kiri Jun 8 at 7:09
    
I am not sure if this works as you want. https://mydoamin.com/{controller}/{action}/{actionurl}={para‌​m} seems not to be a valid URL to me. The part {actionurl}={param} is probably the query part which is comes as a key/value pair and starts always with a ?. You could probably fix your routing if your desired URL would look like https://mydoamin.com/{controller}/{action}/?key1=value1&key2‌​=value2 – Rico Herlt Jun 8 at 8:02
    
It's work, which I need. Thanks Rico. – vishal Kiri Jun 8 at 12:29
up vote 0 down vote accepted

I found the answer for my question. Just define new custom route in your startup.cs file before your default route.

routes.MapRoute(
    "Member",                                             // Route name
    "{actionURL}",                                        // URL with parameters
        new { controller = "Pages", action = "Details" }  // Parameter defaults
);

It's working form me.

share|improve this answer
    
Please mark the answer as correct, even if you found a solution yourself – Tseng Jun 20 at 14:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.