❔ Remove Index from URL
How do I remove "Index" from Url, so I can call
/Home
, /Users
, etc, wihtout additional /index
. (but obv be still redirected to "Index" method in controller.
I found this snipped and added it to my startup
Well, the Index is still there, and all actions without "Index" are redirected to my Users/edit/{id}
action..14 Replies
Without the rest of the code it's difficult to tell
Which part would be helpful? Controllers?
Controller, yes
Should I specify [Route] for each method?
You definitely can, but easier should be mapping a route without {action} or setting it as default equals to Index.
But this be something like:
The
localhost/
shows like /Home/Index
the /Home
shows like /User/Edit
The /Container
shows like /User/Edit
I dont get it ..
hm, could this be an issue with my Users.Edit?
Try commenting it out and see what happens
Yeah, if I remove it everything works fine
hmm
There is something wrong with edit's httpget attribute.
I don't think is necessary.
Try using just [HttpGet] instead, since {id} is set in defaul route...
yeah i removed the [httpGet ] and it works fine, gonna keep it like this for now
It is apparently adding a new route
thanks for your help 😄
yeah i guess it matched too many routes
everything is going there 😂
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.