Base solution for your next web application
Open Closed

How to Use RedirectAction in ApplicationService #3991


User avatar
0
ajayak created

When I add Microsoft.AspNetCore.Mvc in ApplicationService solution and use RedirectAction, it causes server error. I also tried installing AbpAspNetCore package but still no luck.

Is there any other way to perform a redirect?


6 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Please show:

    • your code, and

    • the error log. Can you also find out whether the error occurs when you:

    • create a RedirectAction, or

    • return it? You can do this by assigning it to a variable and setting a breakpoint before you return it.

    If it's Case 1, you can create and inject IRedirectionDelegate interface in Application project. Then implement and register that in Web.Mvc project where the action (and controller) exists.

  • User Avatar
    0
    ajayak created

    Hi @aaron,

    This is in continuation to #3984. All the problems go away after I removed Microsoft.AspNetCore.Mvc from ApplicationService. But I'm still stuck with Redirect.

    I believe creating IRedirectionDelegate could solve my problem. Can you share a sample for that? :)

  • User Avatar
    0
    aaron created
    Support Team

    Ah, you said RedirectAction in this post, but you're getting the url string from _shopifyManager in that post. Since you're not redirecting to a controller action, that suggestion may not be relevant in solving your issue.

    Please avoid creating multiple posts for the same issue. Update the same post so that we can all further understand. Not receiving replies does not mean we're ignoring it. There isn't enough information to reproduce it and offer a solution.

  • User Avatar
    0
    ajayak created

    Hi @aaron,

    For the previous post, the issue was resolved by removing Microsoft.AspNetCore.Mvc. I thought it would be better to create a new post as it is a simple clear thing. Earlier post was a mess. Apologies for that.

    I am facing this issue.

    public async Task GetShopifyInstall(string shop)
            {
                var redirectUrl = _shopifyManager.GetAuthRedirectUrl(shop);
                //********** How to redirect here?**********
            }
    
  • User Avatar
    0
    aaron created
    Support Team

    How are you currently calling this method from client side?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ajayak,

    As far as I know, you cannot return RedirectAction to angular, you must return JsonResult.