如何为连接到MS SQL数据库并从数据库中检索存储过程值的ASP.net网站创建JSON API? [英] How to create a JSON api for ASP.net website that connect to MS SQL Database and retrieve stored procedures values from the database?

查看:51
本文介绍了如何为连接到MS SQL数据库并从数据库中检索存储过程值的ASP.net网站创建JSON API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Android应用程序,它将与该网站在asp.net中的现有网站进行通信如何让他们两个进行通信我不知道我读到有关json但是如何实现它并与之相关网络服务或网站没有任何想法,所以任何有关这方面的建议将不胜感激,例如,如果我从Android应用程序登录,用户应该从该应用程序登录网站用户帐户,当有人从应用程序注册时用户应该在应用程序上自动创建。

I want to create the android app which will communicate with the existing website the site is in asp.net how to make both of them communicate i dont have any idea i read about json but how to implement it and to conncet it with the webservice or the website dont have any ideas, so any suggestions regarding this will be appreciated, For example if i log in from the android app the user should be logged on the website user account from that app and when someone signs up from the app user should be automatically created on the app.

推荐答案

我不认为在两侧登录用户都是个好主意。由于您使用的是ASP.NET技术,因此您必须知道有一个专为ASP.NET开发人员设计的Web API,您可以使用它。他们在JSON中提供了一些你可以在这里使用的细节。



如果这是我的应用程序,我会使用任何服务(网页,Web窗体,MVC)对于我在ASP.NET中的网站,我会设计Android应用程序尽可能多地启用会话。



之后,我会为我的网站开发API,帮助我通过执行一组命令从数据库中取出数据。您应该知道HTTPS足够强大,可以为整个Framework提供支持,您绝对可以在应用程序中使用它。 Web API是ASP.NET的一项功能,它允许您使用HTTPS并允许交叉(远程)设备连接到您的服务并进行通信。就像互联网上的任何其他应用程序一样。



之后你可以创建一些对象,使用Web API的类,你只需转发用户的令牌到网站并在网站上使用它。您无需在双方(移动设备和网站)登录他,只需为用户使用API​​令牌并使用它即可。数据库工作和其他内容将在桌面上进行管理,结果将以JSON格式传回给用户。在Android应用程序中,您可以使用任何Java插件来使用JSON,或者您可以开发自己的插件来使用JSON并从JSON树中提取数据。



请记住,Web API足够强大,可以同时运行这两个设备。因此,您不必双方都登录用户,API会处理它。您只需处理来自服务器的请求和响应。如果您是ASP.NET的新手,那么我会要求您首先学习ASP.NET MVC,这是ASP.NET的企业级,并允许您轻松地使用业务级项目。祝你好运兄弟!



http://www.asp.net/ web-api [ ^ ]
I don't think logging the user on both the sides would be a good idea. Since you're using the ASP.NET Technology you must know there is a Web API designed for ASP.NET developers that you can make use of. They provide some details in JSON too that you can use here.

If this was my application, I would have used any service (Web Pages, Web Forms, MVC) for my website in ASP.NET and I would have designed the Android Application to be as much Session enabled as it could be.

After that, I would develop the API for my website that would help me to take out the data from the Database by executing a set of commands. You should know HTTPS is powerfull enough to power entire Framework and you can definitely use it in your applications. Web API is a feature of ASP.NET that lets you to use HTTPS and allow the cross (remote) devices to connect to your service and communicate. Just like any other Application on the Internet.

After that you can create some objects, classes to work with and using the Web API, you can simply forward the user's token to the website and work with it on the website. You don't need to login him on the both sides (mobile and website) you can simply use the API token for the user and work with it. Database work and other stuff would be managed on the Desktop and the result would be passed back to the user in the format of JSON. In Android application, you can use any plugin for Java to work with JSON or you can develop your own plugin to work with JSON and extract the data from the JSON tree.

Remember, Web API is powerfull enough to run both devices on the same time. So you won't have to login the user on both sides, API would handle it. You just need to handle the request and the response from the server. If you're a newbie to the ASP.NET then I would ask you to first learn ASP.NET MVC which is an enterprise level of the ASP.NET and allows you to work with business level projects easily. Good luck brother!

http://www.asp.net/web-api[^]


这篇关于如何为连接到MS SQL数据库并从数据库中检索存储过程值的ASP.net网站创建JSON API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆