0

I have a MVC application for users to make requests, database schema something like this:

Request(RequestID, RequestType,...)

CarKey(CarKeyID, RequestID,...)

DoorKey(DoorKeyID, RequestID,...)

CarKey and DoorKey are different request types.

Let's say I have one CardKey request with a RequestID = 10, CarKeyID = 3, one DoorKey request with a RequestID = 11 and DoorKeyID = 4

My search result page shows all the requests with links like this:

http://localhost/Requests/10

When user click on this link, since it's a CarKey request, how do I route it to my CarKey controller's Edit action with RequestID = 10 or CarKeyID = 3 ?

Meidi
  • 562
  • 1
  • 8
  • 28
  • How do you know it is a CarKey request from that URL? – krillgar Dec 29 '15 at 20:06
  • That's my question. I was thinking if I can determine in the Request Controller's Details action and send it to CarKey controller Edit action with CarKeyID = 3? – Meidi Dec 29 '15 at 20:12

1 Answers1

0

After doing some research, I found this is very useful:

RedirectToAction with parameter

So What I did was to change return type in my RequestsController's Details action to

var carKeyID = request.CarKeys.First().CarKeyID;

return RedirectToAction("Edit","CarKeys", new { id = carKeyID});
Community
  • 1
  • 1
Meidi
  • 562
  • 1
  • 8
  • 28