Base solution for your next web application
Open Closed

RedirectResult Causes Server Error #3985


User avatar
0
ajayak created

I have created the following function:

public async Task<RedirectResult> Install(string shop)
        {
            if (!await GenericHelper.IsValidShopDomainAsync(shop))
            {
                throw new UserFriendlyException(L("PP_Invalid_Shopify_Url"));
            }
            return new RedirectResult(_shopifyManager.GetAuthRedirectUrl(shop));
        }

In the code block, when user hits the last line(return new RedirectResult), I am getting following error on client: ![image]( <a class="postlink" href="https://imgur.com/a/qdwfc">https://imgur.com/a/qdwfc</a> )

2shopifyplay.myshopify.com/admin/oauth/authorize?client_id=da2faafba7cc7898876351c74ae39446&scope=read_customers,write_customers&redirect_uri=http://localhost:5000/api/services/app/Shopify/Auth:1 OPTIONS <a class="postlink" href="https://shopifyplay.myshopify.com/admin/oauth/authorize?client_id=da2faafba7cc7898876351c74ae39446&scope=read_customers,write_customers&redirect_uri=http://localhost:5000/api/services/app/Shopify/Auth">https://shopifyplay.myshopify.com/admin ... opify/Auth</a> 404 (Not Found) sales-channel:1 Failed to load <a class="postlink" href="https://shopifyplay.myshopify.com/admin/oauth/authorize?client_id=da2faafba7cc7898876351c74ae39446&scope=read_customers,write_customers&redirect_uri=http://localhost:5000/api/services/app/Shopify/Auth">https://shopifyplay.myshopify.com/admin ... opify/Auth</a>: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 404. scripts.bundle.js:44583 WARN: scripts.bundle.js:44583 Content-Type is not sent! Subscriber.js:238 HTTP error: 0, webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:238 webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.error @ Subscriber.js:197 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._error @ Subscriber.js:128 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.error @ Subscriber.js:102 webpackJsonp.../../../../rxjs/OuterSubscriber.js.OuterSubscriber.notifyError @ OuterSubscriber.js:22 webpackJsonp.../../../../rxjs/InnerSubscriber.js.InnerSubscriber._error @ InnerSubscriber.js:26 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.error @ Subscriber.js:102 webpackJsonp.../../../../rxjs/observable/ErrorObservable.js.ErrorObservable._subscribe @ ErrorObservable.js:77 webpackJsonp.../../../../rxjs/Observable.js.Observable._trySubscribe @ Observable.js:171 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:159 subscribeToResult @ subscribeToResult.js:22 webpackJsonp.../../../../rxjs/operator/catch.js.CatchSubscriber.error @ catch.js:111 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._error @ Subscriber.js:128 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.error @ Subscriber.js:102 webpackJsonp.../../../../rxjs/OuterSubscriber.js.OuterSubscriber.notifyError @ OuterSubscriber.js:22 webpackJsonp.../../../../rxjs/InnerSubscriber.js.InnerSubscriber._error @ InnerSubscriber.js:26 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.error @ Subscriber.js:102 webpackJsonp.../../../../rxjs/observable/ErrorObservable.js.ErrorObservable._subscribe @ ErrorObservable.js:77 webpackJsonp.../../../../rxjs/Observable.js.Observable._trySubscribe @ Observable.js:171 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:159 subscribeToResult @ subscribeToResult.js:22 webpackJsonp.../../../../rxjs/operator/catch.js.CatchSubscriber.error @ catch.js:111 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._error @ Subscriber.js:128 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.error @ Subscriber.js:102 onError @ http.es5.js:1244 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:425 onInvokeTask @ core.es5.js:3881 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:424 webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask @ zone.js:192 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:499 invokeTask @ zone.js:1427 globalZoneAwareCallback @ zone.js:1445 XMLHttpRequest.send (async) scheduleTask @ zone.js:2744 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:411 onScheduleTask @ zone.js:301 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:405 webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:236 webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleMacroTask @ zone.js:259 (anonymous) @ zone.js:2769 proto.(anonymous function) @ zone.js:1274 (anonymous) @ http.es5.js:1275 webpackJsonp.../../../../rxjs/Observable.js.Observable._trySubscribe @ Observable.js:171 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:159 webpackJsonp.../../../../rxjs/operator/map.js.MapOperator.call @ map.js:54 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:156 webpackJsonp.../../../../rxjs/operator/catch.js.CatchOperator.call @ catch.js:79 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:156 webpackJsonp.../../../../rxjs/operator/mergeMap.js.MergeMapOperator.call @ mergeMap.js:85 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:156 webpackJsonp.../../../../rxjs/operator/catch.js.CatchOperator.call @ catch.js:79 webpackJsonp.../../../../rxjs/Observable.js.Observable.subscribe @ Observable.js:156 SalesChannelComponent._this.installShopify @ sales-channel.component.ts:21 (anonymous) @ SalesChannelComponent.html:17 handleEvent @ core.es5.js:12023 callWithDebugContext @ core.es5.js:13493 debugHandleEvent @ core.es5.js:13081 dispatchEvent @ core.es5.js:8615 (anonymous) @ core.es5.js:10783 schedulerFn @ core.es5.js:3647 webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:238 webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.next @ Subscriber.js:185 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._next @ Subscriber.js:125 webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next @ Subscriber.js:89 webpackJsonp.../../../../rxjs/Subject.js.Subject.next @ Subject.js:55 webpackJsonp.../../../core/@angular/core.es5.js.EventEmitter.emit @ core.es5.js:3621 webpackJsonp.../../../forms/@angular/forms.es5.js.NgForm.onSubmit @ forms.es5.js:4032 (anonymous) @ SalesChannelComponent.html:17 handleEvent @ core.es5.js:12023 callWithDebugContext @ core.es5.js:13493 debugHandleEvent @ core.es5.js:13081 dispatchEvent @ core.es5.js:8615 (anonymous) @ core.es5.js:9226 (anonymous) @ platform-browser.es5.js:2651 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:425 onInvokeTask @ core.es5.js:3881 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:424 webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask @ zone.js:192 webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:499 invokeTask @ zone.js:1427 globalZoneAwareCallback @ zone.js:1445


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ajayak,

    You should not use RedirectResult, as far as I know this cannot be used in angular. Instead of RedirectResult, you should return JsonResult.