Are these usages of OWIN possible? - asp.net

Is it possible to write a simple custom Console Application that includes a owin library that can host a Asp.Net Web Application directly (without katana.exe, like CassiniDev's library)?
Is it possible to let an Asp.Net Web Application including MVC 4, Web API, SignalR features hosted across IIS and owin, without / rarely changing code?

For hosting applications from the ASP .NET framework family on top of OWIN, as of this post, you can do so with WebAPI and SignalR. If you need something more like MVC and Razor, you can look at using the NancyFX web app framework for that. Maybe in future versions of MVC OWIN support will be enabled

I did an initial implementation of adapter at https://github.com/ashmind/Gate.Adapters.AspNet.
It is absolutely not production ready, but if the functionality is important for you you are welcome to test/extend it.
As far as I know there is no other reliable library for that.

Related

Host ASP.NET App In WCF or Generic Web Server

Objective:
We have a Windows Service/generic EXE that also hosts a WCF service (.Net 3.5). I'd like to be able to take a third party ASP.NET component in a DLL, and host it through that WCF Service.
Is this possible to do, in any way?
It seems like if you want to host a ASP.NET app, it must be through IIS, but we don't use IIS.
Is there any way that we could load the ASP.NET app into memory, make the app available through an endpoint, and receive requests back from the app?
Specifically, we'd like to take the "Microsoft.ReportViewer.WebForms.dll", expose the web form in a web page, and accept any requests back from the web form.
http://msdn.microsoft.com/en-us/library/ms251723.aspx
Looking for anything to get me started. Thx.
From owin.org
"OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development, and, by being an open standard, stimulate the open source ecosystem of .NET web development tools."
Essentially Owin implementations, like Katana (OWIN implementations for Microsoft servers and frameworks.), help you self host web apps, even in a Windows NT Service.
According to this post, hosting a WebForms app outside IIS/ASP.NET is not possible.
WebForms are tightly coupled to ASP.NET/IIS and cannot run directly on
OWIN/Katana (e.g. outside of ASP.NET/IIS). However, you should be able
to use Katana's middleware (Security, CORS, etc.) in a WebForms
application.
http://katanaproject.codeplex.com/discussions/571291

How to explain Katana and OWIN in simple words and uses?

I have read many articles about the OWIN and Katana projects, but I could not get the whole picture of it.
For a normal web developer who uses ASP.NET:
What exactly is OWIN and what problems does it solve (in simple words). What is its relation to IIS?
Does OWIN replace IIS? if not, in what situations does OWIN best fit?
How could OWIN help me in my daily work projects?
How could OWIN help me in a self-improvement projects?
Regarding the comment above, OWIN is not a framework. OWIN is a specification on how web servers and web applications should be built in order to decouple them and allow movement of ASP.NET applications to environments which were not supported before.
Prior to OWIN, when building ASP.NET application, you were inherently bound to IIS due to the heavy dependency on System.Web assembly.
System.Web is something that has existed ever since ASP (non .NET version) and internally contains many things that you might not even need (such as Web Forms or URL Authorization), which by default all run on every request, thus consuming resources and making ASP.NET applications in general lot slower than its counterparts such as Node.js for example.
OWIN itself does not have any tools, libraries or anything else. It is just a specification.
Katana on the other hand, is a fully developed framework made to make a bridge between current ASP.NET frameworks and OWIN specification. At the moment, Katana has successfully adapted the following ASP.NET frameworks to OWIN:
Web API
Signal R
ASP.NET MVC and Web Forms are still running exclusively via System.Web, and in the long run there is a plan to decouple those as well.
On the other hand, IIS is a good, resourceful host for web servers. Entire ASP.NET performance issues using IIS has deep roots in System.Web only. Up until the recent time, when deciding how will you host your web server, you had two options:
IIS
Self-Host
So if you wanted a performance, you'd go for a self-host option. If you wanted a lot of out-of-the-box features that IIS provides, you'd go for IIS but you'd lose on performance.
Now, there is a 3rd option, a Microsoft library named Helios (current codename) which intends to remove System.Web out of the way, and allow you to use IIS on more "cleaner" way, without any unnecessary libraries or modules. Helios is now in pre-release version, and is waiting for more community feedback in order to make it fully supported Microsoft product.
Hope this explanation clarifies things better for you.
EDIT (Sep 2014):
With ASP.NET vNext being in development, Katana is slowly getting retired. Version 3.0 will most likely be last major release of Katana as a standalone framework.
However, all the concepts introduced with Katana are being integrated into ASP.NET vNext, meaning that programming model will be pretty much the same. Quote from forum post made by David Fowler (Architect of ASP.NET vNext):
vNext is the successor to Katana (which is why they look so similar).
Katana was the beginning of the break away from System.Web and to more
modular components for the web stack. You can see vNext as a
continuation of that work but going much further (new CLR, new Project
System, new http abstractions).
Everything that exists today in Katana will make it's way into vNext.
EDIT (Feb 2015):
ASP.NET vNext is now known as ASP.NET 5 and will be built on top of .NET Core 5. .NET Core 5 is lightweight factored version of .NET Framework, designed to support goals of ASP.NET 5 and .NET Native. However, ASP.NET 5 will be supported by .NET Framework 4.6 as well, that should become available together with .NET Core 5. Both ASP.NET 5 and .NET Core 5 will be licensed under MIT and will accept community contributions.
EDIT (May 2015):
Additionally, ASP.NET Web API brand will be discontinued, however it's technology will be base for new ASP.NET MVC 6. Previous ASP.NET MVC versions were built by implementing IHttpHandler, an interface defined in System.Web. ASP.NET MVC 6 removes that dependency, making it portable to various platforms and web servers.
EDIT (May 2016):
ASP.NET 5 will officially be renamed to ASP.NET Core starting with Release Candidate 2 that is scheduled to be released soon. Same will apply for Entity Framework 7 which will be renamed to Entity Framework Core. More information about official announcement and reasons behind it can be found on Scott Hanselman's blog post:
ASP.NET 5 is dead - Introducing ASP.NET Core 1.0 and .NET Core 1.0
EDIT (May 2016):
With the release of Release Candidate 2, ASP.NET Core has been modified so that future web apps are actually just .NET Core console apps setup to process incoming HTTP requests. This concept makes ASP.NET Core even more aligned with approach Microsoft has taken with microservices architecture support and its implementation through Azure Service Fabric. More information on can be found on official blog post:
Announcing ASP.NET Core RC2
If I have to define OWIN for myself, that would be: "The best ideas from the Ruby and Node.js web dev communities, coming to .NET"
But this would not help any ASP.NET developer. My own definition would be something along the lines of:
OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application
If I have to answer the questions you've posed, then here it is:
OWIN is an interface specification. It decouples a web applications from IIS.
If you are using ready-made components (which is what Katana is), then some parts of the application functionality are much easier to implement compared compared to old ASP.NET. Authentication with third-party identity providers (Facebook, Twitter) is one example of this.
OWIN is essentially a collection of best practices, which have been proven in web development communities. It shows a way to implement web apps which is very open to extensibility. As each web developer should constantly be on the cutting edge of new technologies, this is one way to stay up to date with the whole web development community and not just .NET. If you learn OWIN, it would be much easier to learn other web development frameworks like Express for node.js or Rack for Ruby, because the practices they use are similar.
I will try to cover it from the practical perspective.
Katana is project name to implement OWIN in Microsoft.
What exactly is OWIN and what problems does it solve (in simple words). What is its relation to IIS?
OWIN (Open Web Interface for .NET) is a standard (OWIN Specification) and Katana is .NET library, you can get nuget from here. OWIN and Katana became somewhat synonymous on the web.
Before OWIN your only option was IIS with OWIN you can use any other application (that has entry point) as web server.
Does OWIN replace IIS? if not, in what situations does OWIN best fit?
No it does not replace IIS, you can use OWIN and IIS there's Microsoft.Owin.Host.SystemWeb nuget for that. It is best fit if you want to optimise/change the way it is handled in IIS, or you want to create your custom web server out of let's say Windows Forms Application.
How could OWIN help me in my daily work projects?
It could reduce your server running costs since your web servers do not need to run on IIS (Windows) anymore (Windows servers are more expensive than Unix based ones, and you could run it on Console Application under Mono in Linux).
How could OWIN help me in a self-improvement projects?
Learning Microsoft.Owin (and other related OWIN libraries) will improve your knowledge on how HTTP communication between client and web server works.
Good read if you want to understand more on what Katana and OWIN is.
What is OWIN?
OWIN stands for Open Web Interface for .NET. OWIN is a specification that describes how web development frameworks such as ASP.NET MVC should interact with the web servers. The goal of OWIN is to decouple web applications from the web server by introducing an abstraction layer. Such an abstraction enables you to run the same application on all the web servers that support OWIN. Additionally, it simplifies the overall system because the abstraction layer can provide a lightweight infrastructure to host the applications. IIS provides a rich set of features to the web applications. However, web applications may not need all these features. It might be sufficient for them to have minimal HTTP processing capabilities. OWIN compatible host can provide such a hosting environment to these applications. Moreover, you can define a pipeline of modules that are used during the request processing. An OWIN pipeline is a chain of OWIN compatible components through which a request passes.
What is Katana?
Katana is a set of components by Microsoft built using OWIN specifications. Some of these components include Web API, ASP.NET Identity and SignalR.
Above is extract from CodeGuru Article : http://www.codeguru.com/csharp/.net/net_asp/overview-of-owin-and-katana.htm

Is Web Service in ASP.NET obsolete? What to use with ASP.NET 4.0?

I have to write a simple Web Service application in ASP.NET. I read somewhere that Web Services is now obsolete and some new technologies like WCF is there.
But as the name suggests, Windows Communication Foundation, might me restricted to WinForms applications only and not for ASP.NET. What shall I use with Visual Studio 2010?
I want to build a simple Web Forms application and not MVC.
What shall I use with Visual Studio 2010?
You have many choices other than ASP.NET Web Services which are completely obsolete now. So if you are starting a new project and need to develop a web service you might consider:
WCF
ASP.NET Web API
ServcieStack
ASP.NET MVC
But as the name suggests, Windows Communication Foundation, might me
restricted to WinForms applications only
The name is misleading. WCF has strictly nothing to do with Windows Forms only. You could host a WCF service in an ASP.NET application or self-host it if you want.
Simple Web Service application in ASP.NET (webForm OR mvc) ?
My firt choice : ASP.NET WebApi
Easy to unit test
Easy to secure
Restful
Still, WCF is pretty cool too because it is very well integrated with VS, and easy to configure through web.config
Both WebApi and WCF make it possible to version your web services.

can i use wcf rest service in my asp.net 3.5 web application

I heard that rest services are moved from wcf to asp.net web api frame work.
Our web application is built on vs 2010 (asp.Net 3.5) .So still i can use wcf rest services in my web application?
Please suggest some alternatives if it is not possible.
WCF can still be used to build RESTful services1, many services are already built with it and it's not going away. What you heard is that most of the new developments in terms of new functionality in the area by Microsoft will be made in the ASP.NET Web API framework, not in WCF. But as all the services out there can attest, WCF for building web services is still a valid alternative, if it does all you need.
1 The official name is actually "WCF Web HTTP Services"; REST is a well-defined set of constraints which need to be implemented, which would give the service some useful properties. There are some people who argue that people should stop using the term REST for all HTTP-based, non-SOAP services.

Need to develop a RESTful API (both JSON and XML)

I'm looking to make a RESTful API on ASP.NET for a website. My problem is that I need it to be integrated into the website and not as a separate project.
I understand that WCF makes this really easy and its the ideal way to do it, but I don't think you can combine a WCF Service Project and a ASP.Net Website, Is this correct?
Is there a way we can do this using a webservice (asmx) file (since I know that asmx services use SOAP no?)
The reason I need this to be in the same project is that the customer will be able to purchase ssl for their domain (which the website is going to use) and I need to make the API secure as well, but the customer should not be asked to purchase two ssl or even a wildcard one.
Knowing this, is there a better easier way of doing this using WCF?
Take a look at the new MVC4 Beta, it's set to go live sometime between March and April this year and should be able to accommodate your requirement to build a RESTful web service alongside a web application. I haven't spent too much time with MVC4 to go into the details, but it's definitely worth a look. Links: Get MVC4; MVC4 and WebAPI blog.
Hope this helps!
You can use ASPNET MVC to build an API along with your website.
See How can I implement a site with ASP.NET MVC without using Visual Studio? for some details on building a basic MVC site.
ASPNET MVC services can respond in JSON or XML, or both.
There will be no special requirement for two SSL certs.
I have an ASP.NET MVC 3 application that exposes both WCF REST services. I'm using .NET 4. You'll have to pay attention to how you configure your routing. For example, my WCF services are prefixed with something like "api/v1/" while all other requests are handled by ASP.NET MVC 3.
I had a problem because IIS refused to serve some "localhost" requests (like when your MVC 3 controllers try to consume your WCF rest services). That was solved by adding an entry to my hosts file. Also be aware of this when implementing an OAuth 2.0 Resource Server or Authorization Server.
Using WCF for REST services works ok in .NET 4, but the JSON serialization sucks big time. There are issues with default dates and it is rather slow. You may want to look at using a different serializer. With WCF you sacrifice some flexibility for some features you get for free.
ASP.NET MVC 4 (and the WEBAPI) is still in BETA, so I'd avoid that for a project with a short term release date.
I'd actually use NancyFX. Setting up routes is super-easy, and it comes with built in XML and JSON serializers that act based on the data in the headers.

Resources