Hi,
In my MVC application I want to redirect to an aspx page from an api controller. I tried adding the code but its not working. Can someone please check it and help me to fix the issue.
api controller:

Action Method in Home controller

Hi,
In my MVC application I want to redirect to an aspx page from an api controller. I tried adding the code but its not working. Can someone please check it and help me to fix the issue.
api controller:

Action Method in Home controller

Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Naimish MakwanaPosted Jan 17, 2023, 10:43 AM
Please try the below solution.
Or refer below link. That will help you.
https://stackoverflow.com/questions/33548370/redirect-from-apicontroller-action-to-other-mvc-controller-action
Thanks.
Pasang TamangPosted Jan 17, 2023, 10:53 AM
Hi,
In real scenario, redirect to page from API is not recommended. API are more focus to make communication between your UI and backend part. You can follow as suggested by @Naimish Makwana. Another way is You can return the URL that you want to redirect. When you consume the API you will get URL in response and you make a redirection to the URL you get from response.
Just an example, below code will return URL as response. Client app will catch this URL and make a redirection in client app.
I hope this will make sense to you :)
Regards,
Pasang