简体   繁体   中英

asp.net mvc with Angular 4 allow POST from external site

We have a Angular 4 app using asp.net mvc. And the problem that we are having is that when an external site, in this case DIBS payment portal, tries to do a redirect back to our page using POST, we get a 404 not found. The URL is correct and works, but now when the external site uses POST, it doesn't work.

Any ideas on how to deal with this? In our startup.cs Configure method we have this :

 app.Use(async (context, next) =>
        {
            await next();

            if (context.Response.StatusCode == 404
                && !Path.HasExtension(context.Request.Path.Value))
            {
                context.Request.Path = "/index.html";
                await next();
            }
        });

If a resource was not found, the request should now be passed to DefaultFiles and then to StaticFiles serving index.html

Have you added this bit to your "Configure" method?

 app.UseDefaultFiles();
 app.UseStaticFiles();

我通过创建一个处理POST的api控制器解决了该问题,该api控制器返回并重定向到请求的页面。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM