MVC RedirectToAction is not working properly

In one of my controllers, I have a return that looks like this:

return RedirectToAction("AdministerFiles/ViewDataFiles?catid=14"); 

but when it outputs the result to the browser, the line becomes the following:

 AdministerFiles/AdministerFiles/ViewDataFiles%3fcatid%3d14 

how can i solve this? thanks.

0
source share
1 answer

You just need the action as a parameter (along with the route data):

 return RedirectToAction("ViewDataFiles", new { catid = 14 }); 

If you also want to specify a controller (by default, it corresponds to the current controller), you can do this as follows:

 return RedirectToAction("ViewDataFiles", "AdministerFiles", new { catid = 14 }); 
+10
source

Source: https://habr.com/ru/post/1261840/


All Articles