简体   繁体   English

使用 Asp.net 核心 Web Api 反应本机

[英]React Native with Asp.net Core Web Api

I have developed asp.net core web project,我开发了asp.net核心web项目,

Which is working perfect.哪个工作完美。

Now i want to extend my dot net with web api and then i want to build mobile app with react native.现在我想用 web api 扩展我的点网,然后我想用原生反应构建移动应用程序。

I have searched a lot for react native with asp.core web api sample.我已经用 asp.core web api 示例搜索了很多反应本机。

But i couldn't find any.但我找不到任何东西。 I don't know whether it is good to use react native with asp.net core or not.我不知道使用带有 asp.net 内核的 react native 是否好。

Please if any body has any git repo or any good guide for that refer me.请如果任何机构有任何 git 回购或任何好的指南推荐给我。

Thanks谢谢

I'm embarking on the same path at the moment.我现在正走在同样的道路上。 I have a website written in React JS and want to add apps using React Native.我有一个用 React JS 编写的网站,并想使用 React Native 添加应用程序。 All the services are working and in place, so as such it will be possible to write React Native apps (many converted over from React JS by hand).所有的服务都在工作并就位,因此可以编写 React Native 应用程序(许多是手动从 React JS 转换而来的)。 All I need to do then is to call my dotnet core Restful Apis and happy days.然后我需要做的就是调用我的 dotnet core Restful APIs 和快乐的日子。 I envisage no real issues with the approach.我认为这种方法没有真正的问题。

The link https://rapidapi.com/blog/how-to-make-rest-api-calls-in-react-native/ shows how to call the api from React Native and I am sure there are countless other examples to follow.链接https://rapidapi.com/blog/how-to-make-rest-api-calls-in-react-native/显示了如何从 React Native 调用 api,我相信还有无数其他示例可以遵循. All these should be fairly straightforward.所有这些都应该相当简单。

IF anyone know a better approach please advise as I am eager to pick the best route through this.如果有人知道更好的方法,请提出建议,因为我渴望通过此方法选择最佳路线。

The best I can think of is the .NET Core 3 + React template that you can find when creating a project in Visual Studio.我能想到的最好的是 .NET Core 3 + React 模板,您可以在 Visual Studio 中创建项目时找到它。 You can add authorization and it will be ready to use both in React and .NET (OidController).您可以添加授权,它可以在 React 和 .NET (OidController) 中使用。

在此处输入图像描述

在此处输入图像描述

It's a very good template.这是一个非常好的模板。 I can also recommend the Angular version as well.我也可以推荐 Angular 版本。 The only thing that is missing is the refresh token upgrade (it uses JWT access token) and you should add some more code to Identity to use a refresh token (you need a refresh token to generate new access token if your bearer token expires after 20-30 minutes AFK on the website).唯一缺少的是刷新令牌升级(它使用 JWT 访问令牌),您应该向身份添加更多代码以使用刷新令牌(如果您的不记名令牌在 20 后过期,则需要刷新令牌来生成新的访问令牌-30 分钟 AFK 在网站上)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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