SignalR, SharePoint, Owin issue - asp.net

There is a scenario where we have two applications. One is share point and other obe is Web API.
For security point of view, we need to deploy second stand alone project into the firsy application.
In IIS, I deployed one application. In that folder I deployed another application and make it as web application.
Now everythings runs fine. SharePoint applicantion consume APIs correctly.
Now, I have include signalR to both application where web api application is server and share point is client.
I have global asax file and add startup file for owin signalR. If I add owin automatic startup to false then application runs fine but signalR will not work.
If I start owin then neither api work nor signalR will work.
Important point is when I run SharePoint application from IIS and run web api from visual studio and set path of web api for signalR then it works fine.
What could be the issue?

Related

Web API as a windows service

So I'm creating a new .Net Framework 4.8 Web API in Visual Studio 2019 and I'm wanting to know how to create the API as a windows service? I can't seem to find any examples or online resources to do so. I can run the API locally in VS and it opens Chrome and shows the responses under the local IIS Server it spins up. How do I take this same project and compile it as a windows service while still using HTTPS?
Web API is fully capable of being self hosted on top of OWIN, and does not require IIS to run.
Web API self hosted is basically just a console app. So the techniques for turning a Web API console app into a Windows Service are the same as for any other .NET console app. You can use a service manager such as NSSM, or create a Windows service project directly (by inheriting from the appropriate classes, pretty messy) or use a library like TopShelf.
Note that it's generally not a good idea to directly expose this self hosted app directly to the public. IIS provides a lot of security benefits out of the box designed to protect against malicious requests. If you're planning to publicly expose it, make sure you stick a proxy in front of it that will fulfill those security needs.

How to configure and call non-anonymous WCF services from SharePoint application and WPF?

We have a CRM/ERP web application (ASP.Net Forms) running on top of SharePoint (WSS and 201x).
On the other hand we have add-ins for Office (WPF) closely integrated to the web application via WCF services.
Both rely heavily on a WCF services project, in three ways:
WCF services called from code behind
AJAX-enabled client web services using webhttpbinding / enablewebscript
WCF services called from the add-ins.
However, there is a security concern.
In our current set-up, the WCF services need to be set to Anonymous authentication.
Otherwise our web application and add-ins won't work using the current configuration.
Our goal: to disable the anonymous access to the WCF services somehow, without breaking either the web application or add-ins.
This proved much less straight-forward than expected.
This is our typical set-up:
Extended SharePoint site (WSS / 201x). Alternate Access Mapping
configuration:
Default: Active Directory, NTLM.
Intranet: Membership Provider, Anonymous access.
ASP.Net web application runs within the main SharePoint web application (no sub web application in IIS).
WCF services project is configured in IIS as a 'sub' web application beneath the SharePoint web application.
This is what we came up with so far:
Added in the WCF services web.config
Changed Windows Authentication -> Advanced Settings to the following:
Extended Protection: Accept
[X] Enable Kernel-mode authentication
Changed client binding configuration of add-ins and web application to Security Mode TransportCredentialOnly with clientCredentialType Ntlm.
Above solution works in our SharePoint 2007 test environment in all three aforementioned places.
However in SharePoint 201x we can't get the WCF calls from within the web application to work.
At least not using the same client bindings as the add-ins (while the WCF calls from the add-ins also work in SharePoint 2013).
The error message we’re getting is: No credentials are available in the security package.
Another one we encountered is: Provider type not defined. (Exception from HRESULT: 0x80090017)
Question: How can we use WCF services non-anonymously from within a SharePoint web application and from WPF?
Any idea's on how to configure and call these in this scenario? (one way or another)
Any thoughts on this are greatly appreciated!

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

SignalR and SelfHosting ASPNet app

I have an ASPnet webapplication that uses SignalR, it works fine under IIS.
When I try to self host the ASP.NET webapplication with System.Web.ApplicationHost.CreateApplicationHost, The signalR functionality is gone.
From debugging, I see that the OWin Startup class is never hit.
Does anyone have a clue why? From what I understand, the CreateApplicationHost is just hosting the application outside of IIS, but it still runs through the ASP.NET pipeline, So, I don't understand why Owin startup and SignalR wont work.
When hosted inside of ASP.NET, OWIN-based applications require the IIS integrated pipeline. CreateApplicationHost forces use of the ASP.NET classic pipeline.
If you want to self-host, use the HttpListener-based OWIN host rather than trying to self-host ASP.NET directly.
For instructions on self-hosting SignalR, see the following tutorial:
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self-host

Chat application (in Web Garden): SignalR + Redis vs WebService

I have created a chat for an ASP.NET WebForms application. I used SignalR (without Redis) to create the chat component. Everything worked accordingly on my dev machine.
Once the application got deployed to the IIS the SignalR chat stopped working. The reason I found is that the IIS server is configured as a web garden and SignalR is built to work on a single worker (more explanations here).
After reading the link above and some search I found that I could use SignalR + Redis to overcome the Web Garden issue. But, I also saw examples of AJAX WCF Services powered chat apps.
Which of the two is a better way to build a chat application, taking into account the Web Garden issue and the fact that deployment is done on a Windows machine (I read Redis works best on Linux)?

Resources