Reputation: 1411
In my ASP MVC controller I want to redirect to another controller and action with an id:
int thisEvent = 20;
return Redirect("event/details/?id=" + thisEvent);
It should redirect to /event/details/?id=200 or /event/details/20 For some reason it is not working.
I get this error:
Redirect URI cannot contain newline characters
Upvotes: 1
Views: 3912
Reputation: 26856
Instead of concatenating URI you can use RedirectToAction
, provide controller and action names as well as parameters passed to action and let routing engine create redirection URI for you.
Here I'm supposing from your URI that your controller has name EventController
and action you're redirecting to has name Details
:
return RedirectToAction("Details", "Event", new { id = thisEvent });
Upvotes: 2