How to set MVC web application as a SignalR self-host? - asp.net-mvc

I have searched a lot about SignalR but all I could found that I can only make console application as a self-host and client from script and .net code can access that server. My question is how can we set a MVC Web application as a self-host?
Ref link.

Instead of adding only app.MapSignalR() to my Startup class I added app.UseCors(CorsOptions.AllowAll)as well and MVC based SignalR server is ready to server.

Related

Adding a New REST Service Project to an ASP.Net MVC SPA

I have been developing an ASP.Net Core 2.0 SPA web application in Visual Studio 2017 which started life using the new Angular SPA Template (ASP.Net Core SPA Templates). I now need to add reporting to the website and the Telerik Reporting solution I am trying requires a REST Service to function.
Telerik provide a VS 2017 template for their REST Service which I used to add a new .Net 4.6.1 Project to my Solution with its own ReportsController and associated references and code etc. The Telerik REST Service requires the full .Net framework.
My solution builds and runs, I can view my Angular web application, but if I use Postman to send a request to the new ReportsController I just get a 500 server error. I have added a reference in my SPA project to the REST Service project, which I may not require. Should I somehow configure the new REST Service in my SPA project's startup class?
How do I configure my solution such that the new REST Service is launched and listening for requests from my Angular web application please?

Deploying the ASP.NET Web API

I am creating my first ASP.NET Web API. Created the application, build them and ran the application by calling the URL like http://localhost:35432/api/Sample?id=1&id=83 and returns the JSON file as response.
But I dont see anything with respect to this application on the IIS manager. Where do I find them or do I have to set up something. I am not sure how we will be deploying the application from DEV to TEST server.

MVC Web App using Web API do not work after deploying on IIS

I have created Web application using asp.net MVC architecture.
I have used Web API for getting data from database. Both Web application and Web API are in same project. I have not published Web API separately on IIS.
When I am debugging or running the application through Visual studio it works properly. I have used below code to get data from Web API URL
TODOINfo[] lstToDoInfo = httpClient.GetAsync("http://localhost:65373/api/RESTApi").Result.Content.ReadAsAsync<TODOINfo[]>().Result;
In Above function I am passing url which consist of localhost plus fixed port number. Above code is working fine when running through in Visual studio.
I have published the same code on IIS by doing below changes.
TODOINfo[] lstToDoInfo = httpClient.GetAsync("http://" + sBaseUrl + "/api/RESTApi").Result.Content.ReadAsAsync<TODOINfo[]>().Result;
sBaseUrl value is "localhost".
After Browsing the application on internet explorer getting following error.
No MediaTypeFormatter is available to read an object of type 'TODOINfo[]' from content with media type 'text/html'.
Any information or suggestion regarding above problem is highly appreciate.
Try changing sBaseURL to "localhost/" +yourwebsite
another option would be to change: sBaseURL to: servername/yourwebsite

Browser Links - Nonstop Signalr Calls in MVC 5 application

I've created a new MVC 5 Project in VS2013 and when I create the project I gave the authentication mode to none because I planned to use signalr in my project later.
I didn't install any signalr related files instead of the two signalr js files (in my scripts folder). And there are no any startup class or OWIN.
But when I run my application there are signalr calls going and going using longpooling. These things can be viewed in the firebug console.
Previously I've used signalr with many projects using VS 2012 MVC4 this is the first time I'm using MVC5. And this slows down my application. How this could be happened.
Here is the POST message...
Please help..
This is a dev tool only, it's not actually part of your application. I suggest you read this intro which also tells you how to disable the feature.

Server Variables are not being accessible in ASP.NET MVC

I have two web applications hosted in the same app pool in IIS 7. One is an ASP.NET application and the other is ASP.NET MVC application. When I go to the web application in ASP.NET and click on a link it is supposed to Launch the other web application in MVC hosted in the same app pool. I can access Server Variables in the ASP.NET application, but I can't access Server Variables in ASP.NET MVC. This works in IIS 6.0 but doesn't work in IIS 7.0. Any ideas and suggestions are greatly appreciated.
Thanks in anticipation.
You are not supposed to see the other's app data (be it server variables or whatever). This is normal. Just because they're in the same process this does not provide access to them.

Resources