Building web services as well as their consumer in Visual Studio? - visual-studio

So I'm going to be building two things. The first is a database-driven collection of RESTful web services. The second is a user-facing web application which accesses those services.
I have to do this all in Visual Studio 2010, in MVC2 / C#, for deployment to an IIS6 + SQL Server 2005 environment. I'm not terribly familiar with VS, nor MVC2, nor any of the attendant development and debugging tools.
So, my question is this: How should I structure all this to make life easiest on myself in terms of concurrently developing both pieces? I need to be able to deploy the two pieces to separate servers, but I want to be able to easily test both of them simultaneously on my development machine. Do I make two separate projects? Or is there a way to build a single project with multiple solutions, which can be tested at the same time?
Any advice would be much appreciated.
Thanks!

You could have a single solution containing both web projects for the REST service application (WCF?) and the ASP.NET MVC application and then run them simultaneously using the Visual Studio development server by configuring multiple startup projects:
This will allow you to test/debug them simultaneously.
Another possibility is to use the newly released IIS Express to host both applications (you need to install VS 2010 SP1) which is the solution I would recommend you.

I suggest you follow the NerdDinner tutorial. This sample MVC2 application follows the suggested pattern for developing MVC2 web applications that use services.
http://www.asp.net/mvc/tutorials/introducing-the-nerddinner-tutorial

Related

Recommended server when running ASP.NET Core web apps in Visual Studio

Having a hard time finding the right doc for this particular feature.
Under the green arrow (launch profiles dropdown list) in Visual Studio 2017 I have a menu item named after my project. Is this the Kestrel server option? Is it the default? Is this option (Kestrel) the recommended one to use for ASP.NET Core 2.1 web apps? Is IIS Express considered obsolete?
I think it is a little bit annoying really that there are so many options to choose from. Specially when there's no quick explanation in the IDE and you don't know which is which. It's like having three play buttons in Spotify each doing the same thing but with different names on them. So which one do I click?
I recommend to read these docs:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/?view=aspnetcore-2.1&tabs=aspnetcore2x
ASP.NET Core ships two server implementations:
Kestrel is the default, cross-platform HTTP server for ASP.NET Core.
HTTP.sys is a Windows-only HTTP server based on the HTTP.sys kernel
driver and HTTP Server API. (HTTP.sys is called WebListener in ASP.NET
Core 1.x.)
In simple words ASP.NET Core runs its own HTTP server. Than you can use IIS, IIS Express, Nginx, Apache as reverse proxy.
When you run ASP.NET Core project in Visual Studio you can run in two modes:
Without debugging - it fires up Krestrel and IIS Express.
With debugging - it only fires up Krestrel
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?view=aspnetcore-2.1&tabs=aspnetcore2x

ASP.NET Core launch settings: IIS Express, IIS, Project, Executable

My Google skills are lacking at the moment. When should I be using IIS Express vs. IIS vs. Project vs. Executable? What are the pros/cons of each?
IIS Express: A common default that runs the ASP.NET Core application behind the IIS Express development server. This is a good default.
IIS: When you actually have a full IIS installed, you can set this up, so that your application runs directly behind IIS. That isn’t really a good choice for development, at least not for ASP.NET Core, and I actually don’t even know if this works properly with ASP.NET Core.
Project: This runs the application as a console application. As a result, this is the same as running dotnet run from the command line. This is also a very good option for debugging, as you can directly see the logging output. Depending on your target production environment, this might even make more sense than running behind IIS Express.
Executable: This allows you to run an arbitrary executable. That’s not really useful for running your ASP.NET Core project.
So basically it comes down to IIS Express or Project. These are the two that are also configured properly by default in the launchSettings.json file that comes with the ASP.NET Core application template.
Whether you prefer IIS Express or running the application directly probably comes down to personal preference. So just give both a try and see what feels nicer to you.

Justifying Visual Studio upgrade for REST API project

Our group does not primarily develop in c#/.NET, but a few years ago we picked up a couple of licenses for Visual Studio 2008 for a few projects. Since we do not develop full time in .NET, we have not upgraded Visual Studio since then.
There is a project coming where we need to develop a web application that contains a REST API. We have been looking at all of the documentation that deals with creating REST APIs. It appears that while VS 2008 is capable of creating APIs (with WCF), later versions of Visual Studio seem to have much better support for creating REST APIs (ASP.Net Web API).
My questions are:
Would upgrading to Visual Studio 2012 or 2013 make that much of a difference in the development/maintenance of an API, or is Visual Studio 2008 sufficient?
How can we go about justifying an upgrade in our Visual Studio licenses (if needed)?
We don't want to justify an upgrade by just saying "it is newer so it is better". Are there any documents that show how Visual Studio 2012 or 2013 is much better at creating REST APIs than Visual Studio 2008?
Not sure if is enough to justify the money but here are some reasons to adopt Visual Studio 2013:
With Visual Studio 2008 you are restricted to .NET Framework 3.5 or lower. If you upgrade you have access to 4.0, 4.5 and future 5.0
If you use Framework 4.5 you can use new REST API Framework.
You can use latest versions of MVC.
You can use latest Microsoft Entity Framework versions (old version can be used in Framework 3.5.1 but you really want the latest version as it has important performance improvement)
You can benefit from ASP.NET WebAPI.
WCF was a way of improving web services, but not the best one. I would avoid WCF if possible.
What is Web API?
ASP.NET Web API is a framework for building web APIs on top of the .NET Framework. You can use the new MVC4 (ASP.NET MVC 4 Web Application project)
using Web API template.
You can actually get Visual Studio 2013 express for free and build all the web API's you'd like. The paid versions include lots of enterprise features and plugin support.
http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
For me, it will always be a factor of the business side of things. If they see the value, it is an easy sell.
If using Framework 4.5.1 (VS2013 required) will reduce both the server resources
(See:
ASP.NET application suspend
Just-In-Time (JIT) performance of 15%
"The .NET Framework 4.5 and Windows 8 introduce features that can help you achieve a significant performance boost for web-server workloads. This includes a reduction (up to 35%) in both startup time and in the memory footprint of web hosting sites that use ASP.NET."
)
AND bandwidth resources
(SEE:
.NET 4.5 and WCF Request Compression
http://www.topwcftutorials.net/2014/03/whats-new-in-wcf-v45.html under Compress and Cache
),
then one can actually do the maths and see if it makes sense already. Then, the developer and maintenance side (which is quite "neat" in Vs2013 - new intellisense, nice nuget, etc.), is just jam. From a developer point of view, you will also need to consider the cost to upgrade the application between versions, i.e. the cost from 2008 to vNext vs. 2013 to vNext.
Update:
As this is a very similar situation I find myself in, I have been doing some research. Our company standards is VS2012 (RE: Microsoft Dynamics environment).
According to "What's New in the .NET Framework 4.5, 4.5.1, and 4.5.2" at http://msdn.microsoft.com/en-us/library/ms171868(v=vs.110).aspx they suggest the following for your domain specific improvements:
•Ability to support multiple authentication modes on a single WCF endpoint when using the HTTP transport and transport security.
This is always a big seller for business. Please look at the other improvements under WCF at the link above.
I have also found an article at http://www.msmsoftware.com/2013/8/6/the-business-benefits-of-upgrading-net-35-to-45.aspx that is very specifically aimed at your question. They note, as I said, better performance, better security and increase development and support functions.
Your question is unique in that it targets the work side of things (WCF), so the fluff around better support for app stores, better web standards, etc. is somewhat pointless. Hopefully I have given you enough to make the answer somewhat clear.

Quick deployment of Visual Studio 2010 app with SQL database

I am new to Visual Studio 2010, so please bear with me. Back in the days of using VB6 combined with an Access database, all I had to do was to use the Package & Deployment wizard and include the database file in the setup. Then all the client had to do was run one setup file and the application would magically run right away (the database would be placed in the App Path).
Is there some way to create a setup file in VS 2010 which will also install SQL Server Express automatically, attach the database along with the application itself?
This is meant for people who do not have SQL server installed and they should be able to start using the app by running one single setup.
Thanks!
Yes, your setup based on Windows Installer and built with Visual Studio itself can deploy everything you need. Read this article on MSDN for more details (maybe you won't need ClickOnce but it contains a lot of links).
I guess you need some clarification about your options (I assume you want to use a Microsoft solution because you talked about SQLExpress).
Microsoft SQL Server: fully featured database engine. It costs (a lot) and deployment isn't easy as we would.
Microsoft SQL Server Express: free edition (with some limits) of the big brother. Same installation issues. Perfect for medium desktop or web applications.
Microsoft LocalDB: single or multiple file, single user, support for stored procedures and advanced data types as in higher versions, easy to deploy and (optionally) per-user execution. Perfect for small/medium desktop applications and developing (with some preconditions with web applications too).
Microsoft SQL Server Compact 4.0: single file, single user, small, in-process, very easy to deploy. Perfect for small single user applications or used as local data storage (VS2k10 C++ Intellisense, for example, uses a SQLCE DB).
Microsoft JET Engine: the old beloved Access. If you come from VB6 I guess you know this.
If (and this is a big IF) your application is intended for a single user and you don't need data-sharing, now Microsoft provides a new version of SQLServer Express called LocalDB.
This version runs as standalone executable (isn't a service).
Its major advantage is the easy installation.
Search for LocalDB or look at my question LocalDB deployment

How to set up Windows Web Server 2008 R2 for MVC Applications

What I am looking for and seem unable to find, it's late and I'm tired, is a step by step guide on how to set up windows 2008 server to run asp.net mvc applications.
I am a web applications developer, amongst other things, and can do that bit fine. Normally I let someone else, like the hosting company, worry about the setup and just publish using 1-Click with web deploy or ftp.
However, for this projects I have a local Windows Web Server 2008 R2 installed but I don't know how to set it up to run the application. the deploy works, all the files arrive in the correct folder on the server, but can I get it to work?
No.
Hence the question.
For your information the app is built using Sharp Architecture, MVC3 and Razor and targeted at .NET 4 which is installed on both my development PC and the server.
Any suggestions?
Thanks.
Best thing would be to download Windows Web Platform installer and select the options you want, for example, .NET 4, MVC3 etc etc ...
Then, remember to enable ASP.NET in your IIS (under Roles or something...).

Resources