Visibility of data with web api and xamarin.forms - asp.net

I am creating small project in xamarin.form (to learn xamarin and mvvm pattern ), where my mobile application will be connect to SQL Server database. On every forum people suggest to use Web Api to get json's from database and next in xamarin application i go under link where is json, parse it and its done. I did an test project which is doing that and it works very well. Unfortunatelly after few days I realized that all data is visible.. If I enter under url/api/subject I get this data in json.
My question is. Should I connect from my xamarin application directly to SQL Database OR is there any way to not showing json's in browser?

To function correctly, many mobile applications are dependent on the cloud, and so integrating web services into mobile applications is a common scenario. The Xamarin platform supports consuming different web service technologies, and includes in-built and third-party support for consuming RESTful, ASMX, and Windows Communication Foundation (WCF) services.
This article discusses this topics.
For customers using Xamarin.Forms, there are complete examples using each of these technologies in the Xamarin.Forms Web Services documentation.
I recommend you learn more about REST architecture

Related

How to create web API and MVC solution separately?

I'm new to the .net application. am trying to develop an application for Accounting Purpose. Am totally confused that how can I use the design pattern, MVC is preferred. I have to use this app both in Desktop and as a mobile app. App should be more secure.
So please guide me how to design the project. Can you please suggest any examples?
WebApi + MVC is good option I think but for this, should I create 2 solution for both API and MVC?
should it work smart phone as well as desktop?
Database-PostgreSQL
Application will have two parts:
Part I – Accessible to the client through the web page
Part II – Back-end accessible only to us (Company) where all the processing is carried out. Perform the initial setup once the client is registered – create the account in the accounting software and create the chart of accounts
Review and process documents
Accounting – the entries will be passed in the application and will be exported to the accounting software
First of all you can find many tutorials out there on the web about creating a ASP.NET MVC project with Web API.
This can be achieved in one solution as you will see in tutorials.
Example: Getting started with ASP.NET Web API
For the desktop and mobile support, I would like to refer to use Responsive Design. Using a library like GetBootstrap you can create websites that change their content dynamically for each type of device ( desktop / tablets / smartphones / ... ).
Now-a-days everything is mobile. So if you are developing something both for Web and mobile app, API has to be the first and only choice.
The reason behind is that--- More or less what Web shows, APP should also show that, but the layouts or UI are different(here comes the client-side). Moreover if APP needs some extra API, I do not think, that would be much overhead if certain extra APIs are written for the APP. Essentially One API codebase suffices both the paradigms.
It is always a good idea to seperate Client-side architecture with server-side architecture.
I would suggest to seperate the client and server(API), and that would be in best of interest.
Your .net application may serve as client side with MVC pattern where M can call API services and C as usually manages the business logic and V displays the results.
You can write API services(server/backend) in .net, nodeJS, PHP, GO any technology which can manage talking to servers. There also you can create certain architecture or flow of your requests.
Hope that helps

Xamarin.Forms app SQL-server database options

I've been studying Xamarin.Forms with goal of building cross-platform mobile app in VisualStudio2015. I've got a perfectly acceptable public facing web site but native app(s) are what the boss thinks we need.
The current web app hosted on IIS 7.5 uses a separate project(DLL) for database access to an on-premises SQL Server 2008 instance. This VStudio project exposes domain objects to the calling ASP.NET webforms by executing various stored procedures using System.Data.SqlClient.
I know building the mobile native app itself with Xamarin.Forms is one part of the challenge but I am asking here for clarification about how to approach the database requirements:
Do I need to create some sort of web service that provides the same CRUD functions required by my current web site?
Xamarin documentation lists several options for consuming web services and the more I search and read about data access I conclude that a callable web service of some type is going to be required for my eventual native mobile app.
Is this assumption correct?
Yes. You generally want a webservice layer brokering requests between your mobile app (or any remote client) and your DB server. If you already have all your crud operations in a separate library that is utilized by your website, then a webservice would just be another set of endpoints that rely on the same CRUD library.

SQL Server and iPad app interaction

I have to write an app for iPad that would take data from SQL Server and post it to the iPad. I looked up on this over the Internet and found that i have to write a web service to expose the data from SQL server using ASP.NET. I did an app previously in android that would take data from my dropbox a/c and display it to the user. I made use of the drop-box api available. I was wondering if anything like that exists for SQL? Also, i have to code in Obj-C for the iPad, so how will
i write ASP.NET code? I have more doubts.
Thanks in advance.
There are many options for web services. If you are developing in ASP.NET and don't want to invest to much time in just accessing the data I would suggest some software that will help you generate the source code.
WSSF (Web Service Software Factory) is software that will assist you in creating a SOAP web service and it generates source code for you. I do recommend however working through a tutorial first before just jumping into using this. WSSF uses visual studio as well.
Once you have a web service that packages your SQL data for communication through http requests. You will need to parse the data communicated in Objective-C. For this you'll find SudzC to be very helpful.
SudzC generates all the source code for accessing your web service in Objective-C, given the WSDL.xml file of your web service (a file that lays out the design of your web service).
Although these software will save you a lot of coding, I wish I could tell you that this will be a short and easy process. However this is vary rarely the case, developing this will take you a couple of days.
I do know that people often use RESTful web services when dealing with the iOS enviroment, although I do not have the same kind of experience with them as I do SOAP web services. I hope that this information is helpful to you.
I've done this. The best way is to use .NET 3.5 or higher to create a WCF (Windows Communication Foundation) project. These projects will let you communicate with your mobile application using REST or SOAP. They also let you send data in XML or JSON format. You will then need to create a REST or SOAP client in your IPad application to communicate with the server.
Use OData. See Creating an OData API for StackOverflow including XML and JSON in 30 minutes for how to publish your SQL Server data as an OData service. See Consuming OData using Objective-C for how to consume the OData service from your iPhone app.

starting on a new project(C# /ASP.NET) , need some guidelines on the framework and infra for the same

so i am going to start on a website which is going to have
Main Website
Mobile Version
Android App
iPhone App
WP7 App
going to start on the website first using .Net Framework 4 , for database will be using the EF4. The website is expected to create lots of traffic.
i want to take advice on how to approach the development , currently evaluating following 2 options
1) Main Website and Mobile website versions talk directly to database and the mobile apps are built upon WCF / Odata .
2nd Option
First build up the WCF /OData webservices and then develop all Main Website / Mobile Website and apps using the data services ( will this make the website slow , assuming all will Database on one box and website + services on the other box)
please pour in your views on both options.
Thanks
I would choose the second option. Have a look at
Web Service Software Factory that will help you build web services correctly, and develop good practices.
ASP.NET MVC i recommend to use it for building web site, and your web services will serve as Model for site.
I would also put wcf services on the same server as database.
Regards, Sergiu.

What is the best architecture for building a .NET website that may also support a native mobile app in the future?

I am in the planning phases of building a new ASP.NET website. The website is really a transactional web application where the users will log in and perform basic CRUD data operations. For right now this website will be accessible through a traditional desktop browser and a mobile browser. For the mobile browser we will build a separate scaled down version of the site.
In the future we may decide to create native mobile applications for Android or iOS devices also.
So the question I have is what is the best way to design the system to easily support that? Here is what I am thinking. I am thinking of building out 3 tiers to the site. The back end will be the database - SQL Server 2008. We will use stored procedures for all data access. The middle tier will be a web services tier. This tier will be built using RESTful web services and will contain all of the business logic. These web services will provide access to the database. The front end will be built using ASP.NET. The front end will only contain presentation logic. These tiers will actually be deployed on physically separate servers.
Then I am thinking that when we decide to build a native Android or iOS app that we could build those apps to simply call the same RESTful web services that the main site is calling.
Does this seem like a reasonable approach? The only thing I can think of is that the way we are building it right now the web services would be behind the firewall and would not be accessible to the outside world. When we want to support a native mobile app then we would need to make the web services accessible to the outside world.
Any thoughts? Does this seem like a good approach for building a high availability, high usage web app that needs to support native mobile apps in the future?
Thanks,
Corey
I'm with Rober Harvey there. With ASP.NET MVC you can make the presentation site in no time, use as Models your web service; with the link that he gave you, set the site for mobile browsing, and use the web services for the mobile apps when you build them.
For me it looks like a good plan. Regarding the web services being public, you can protect yourself by implementing API keys in the web service, so only your apps can use it.

Resources